1
public string this[string columnName]
什么意思当实现IDataErrorInfo接口?`public string this [string columnName]是什么意思`在实现IDataErrorInfo接口时?
public string this[string columnName]
{
get
{
switch (columnName)
{
case "Name":
return ValidateName();
case "PhoneNumber":
return ValidatePhoneNumber();
default:
return string.Empty;
}
}
}
我不明白为什么有方括号和它做什么。
答: 感谢汉斯和斯科特现在我知道,仅仅是一个索引的语法。更多信息here。
具体什么你不明白'这个[字符串COLUMNNAME]'语法,或者你问他们为什么这样做呢? –
查看您最喜爱的C#语言手册中的“索引器”。 –
你必须了解IDataErrorInfo,然后你才会明白This [columnName]的含义,我想这就是为什么你得了一个downvote。 –