TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Aimee jacobs
NA
4
0
problem with properties
Jan 16 2009 11:18 PM
hii all i have a problem in using properties can u plzz lemme know where has my code gone wrong
this is my class
class Class1
{
private int maths;
private int science;
private int social;
private float total;
private float percentage;
//private float div;
private void sum()
{
total = maths + science + social;
percentage = total / 300;
}
public float MyProperty
{
get {
return percentage ;
}
}
public int mathspro { get { return maths;} set {maths = value ;} }
public int sciencepro { get { return science; } set { science = value; } }
public int socialpro { get { return social; } set { social = value; } }
}
}
namespace csharpconstruct
{
class Program
{
static void Main(string[] args)
{
float mess;
Class1 clas = new Class1 ();
clas.mathspro = 70;
clas.sciencepro = 90;
clas.socialpro = 90;
mess = clas.MyProperty;
Console.WriteLine(mess);
}
}
}
Reply
Answers (
3
)
System.StackOverflowException
Confusion over use of static keyword