C# provides a concept called properties to enable you to create object-oriented fields within your classes. Properties use the reserved words get and set to get the values from your variables and set the values in your variables.
class Point
{
int my_X; // my_X is private
public int x
{
get
{
return my_X;
}
set
{
my_X = value;
}
}
}
No comments:
Post a Comment