1var person = {
2 language : "en",
3 get lang() { return this.language; },
4 set lang(lang) { this.language = lang; }
5};
6document.getElementById("demo").innerHTML = person.lang;
7person.lang = "es";
1class Thing {
2 private int secret; // This is a field.
3
4 public int Secret { // This is a property.
5 get {
6 Debug.Print("Somebody is accessing the secret!");
7 return secret;
8 }
9
10 set {
11 Debug.Print("Somebody is writing to the secret!");
12 secret = value; // Note the use of the implicit variable "value" here.
13 }
14 }
15}
16