Hashtable text=new Hashtable();
public string Text [int index]
{
get
{
return text[index];
}
}
直接return text虽然也能成功地get,但这样的话Text属性就不是只读的了。
public string Text [int index]
{
get
{
return text[index];
}
}
直接return text虽然也能成功地get,但这样的话Text属性就不是只读的了。
string str=myClass.Texts[i];
但不能
myClass.Texts[i]=str;
也就是说Texts是一个只读属性数组。
另外,Hashtable有一个IsReadOnly属性,但只能读不能写,那它有没有用?
{
return .....
}
.net里面有类似IReadonlyDictionary的接口吗?
如果你的Texts只定义get过程,上面那句可以编译通过?