public class Button: Control
{
private string caption="bbs";//默认属性
public string Caption {
get {
return caption;
}
set {
caption = value;
Repaint();
}
}
} /*
有了上面的定义,我们就可以对Button进行读取和设置它的Caption属性:*/ Button b = new Button();
b.Caption = "ABC"; // 设置
string s = b.Caption; // 读取
b.Caption += "DEF”; // 读取 & 设置
属性不能带参数.要带参数用函数
{
private string caption="bbs";//默认属性
public string Caption {
get {
return caption;
}
set {
caption = value;
Repaint();
}
}
} /*
有了上面的定义,我们就可以对Button进行读取和设置它的Caption属性:*/ Button b = new Button();
b.Caption = "ABC"; // 设置
string s = b.Caption; // 读取
b.Caption += "DEF”; // 读取 & 设置
属性不能带参数.要带参数用函数
不就是indexer吗? :)