The following code provides a hint of the same
public enum playerType { ClassA, ClassB, ClassC, Contract }
private playerType _PlayerType;
string Name;
string Age;
string Phone;
#endregion
#region properties
public playerType PlayerType
{
//accessor
get { return _PlayerType; }
//mutator
set
{
_PlayerType = value;
}
}
Here _PlayerType is declared as private. This can be however accessed in the main program as shown below:
ClassTeam CT = new ClassTeam();
CT.PlayerType = ClassTeam.playerType.Contract; //Calls the Mutator
MessageBox.Show(CT.PlayerType.ToString()); // Calls the Accessor
The statement CT.PlayerType = ClassTeam.playerType.Contract; Calls the Mutator (set property) and sets the value and CT.PlayerType.ToString() uses Get property and retrieves the value
No comments:
Post a Comment