【发布时间】:2014-06-19 20:24:58
【问题描述】:
是什么
public object this[string name]
做
class ObjectWithProperties
{
Dictionary<string, object> properties = new Dictionary<string, object>();
public object this[string name]
{
get
{
if (properties.ContainsKey(name))
{
return properties[name];
}
return null;
}
set
{
properties[name] = value;
}
}
}
【问题讨论】:
-
你在这里拥有的是 Indexed 属性,你可以在这里阅读更多关于它们的信息msdn.microsoft.com/en-gb/library/aa288464(v=vs.71).aspx