12-Apr-04 (Created: 12-Apr-04) | More in 'CS-dotnet'

A C# property

A C# property


public class SimpleProperty 
{
   private int number = 0;
   public int MyNumber 
   {
   get {  return number; }
   set {  number = value;}
   } 
}
public class UsesSimpleProperty
{
   public static void Main()
   {
      SimpleProperty example = new SimpleProperty();
      example.MyNumber = 5;
      int anumber = example.MyNumber;
   }
}