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;
}
}
}
你這裏有什麼是索引屬性,能夠閱讀到更多安博他們在這裏http://msdn.microsoft.com/en-gb/library/aa288464(v=vs.71).aspx –