Lecture overview -- Keyboard shortcut: 'u'  Previous page: Properties [Section] -- Keyboard shortcut: 'p'  Next page: Properties - Tricky Use -- Keyboard shortcut: 'n'  Lecture notes - all slides together  Annotated slide -- Keyboard shortcut: 't'  Alphabetic index  Help page about these notes  Course home    Data Access, Properties, and Methods - slide 5 : 29

Properties - Basic Use
public class C {
  
  private int v;

  public C(int t){
    v = t;
  }

  public int V {
    get  {return v;}
    set  {v = value;}
  }  
}
using System;
public class Client {

  public static void Main(){

    C x = new C(5);

    x.V = 7;                  // activates setter: v is assigned to 7.
    Console.WriteLine(x.V);   // activates getter: output 7.
  }

}