Choose Category
//MyClass.cs //Demonstrates a property class MyClass { MyType myInternalReference; //Begin property definition public MyType PropertyName{ get { //logic return myInternalReference; } set{ //logic myInternalReference = value; } } //End of property definition }//(Not intended to compile – MyType does not exist)
myClassInstance.MyProperty = someValue; //Calls "set" MyType t = myClassInstance.MyProperty; //Calls "get"