Get Set Property

Ranjeet_8
Posted by Ranjeet_8 under C# category on | Points: 40 | Views : 1108

class Program
{
static void Main(string[] args)
{
MyClass ObjmyClass = new MyClass();

Console.Write("OLD Property Value : ");
Console.WriteLine(ObjmyClass.IntegerField);

ObjmyClass.IntegerField = 7;

Console.Write("NEW Property Value : ");
Console.WriteLine(ObjmyClass.IntegerField);
Console.Read();

}
}


public class MyClass
{
private int integerField = 3;

public int IntegerField
{
get
{
return integerField;
}
set
{
integerField = value;
}
}
}

Comments or Responses

Login to post response