C# Properties
//private field variable
private string name;
//public property provides access to modify private field: name.
public string Name{ //property
get{
return name;
}
set{
name = value;
}
}
//example usage - object from class that implements property
string objName = MyObject.Name; //getting the name value
MyObject.Name = "Same"; //setting the value of nameProperties Hide Class Implementation Details
Last updated