get set is code example
Example 1: set get javascript
var person = {
language : "en",
get lang() { return this.language; },
set lang(lang) { this.language = lang; }
};
document.getElementById("demo").innerHTML = person.lang;
person.lang = "es";
Example 2: get set
class Thing {
private int secret; // This is a field.
public int Secret { // This is a property.
get {
Debug.Print("Somebody is accessing the secret!");
return secret;
}
set {
Debug.Print("Somebody is writing to the secret!");
secret = value; // Note the use of the implicit variable "value" here.
}
}
}