For the following code, I don't quiet understand what is the meaning of "{0}" presented in both getter and setter, I know it is referring to a index number but why it should be 0 ? I'm also confused about the variable "value". Is this just a place parameter like we used in Java ?
Thank you.
void Main() {
Button b = new Button();
b.Caption = "abc";
string c = b.Caption;
Console.WriteLine("c = {0}\r\n", c);
Button p = new Button{Caption = "cool"};
string e = p.Caption;
Console.WriteLine("e = {0}", e);
}
class Button {
private string caption;
public string Caption {
get {
Console.WriteLine("get {0}", caption);
return caption;
}
set {
Console.WriteLine("set {0}", value);
caption = value;
}
}
}