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.
}
}