using System.IO;
using System;
class PropertyClass {
public int MyValue // Auto Implemented Property
{
set;
get;
}
class Auto Implemented Property {
public static void Main(String[] arg) {
PropertyClass propertyObject = new PropertyClass();
int fieldValue;
fieldValue = propertyObject.MyValue; //Get Field Value via Property's set Accessor
Console.WriteLine("MyValue: " + fieldValue);
propertyObject.MyValue = 100; //Set Field Value via Property's set Accessor
fieldValue = propertyObject.MyValue;
Console.WriteLine("MyValue: " + propertyObject.MyValue);
}
}
}Output
MyValue: 0
MyValue: 100
