I have defined a partial class with a property like this:
public partial class Item{
public string this[string key]
{
get
{
if (Fields == null) return null;
if (!Fields.ContainsKey(key))
{
var prop = GetType().GetProperty(key);
if (prop == null) return null;
return prop.GetValue(this, null) as string;
}
object value = Fields[key];
return value as string;
}
set
{
var property = GetType().GetProperty(key);
if (property == null)
{
Fields[key] = value;
}
else
{
property.SetValue(this, value, null);
}
}
}
}
So that i can do:
myItem["key"];
and get the content of the Fields dictionary. But when i build i get:
"member names cannot be the same as their enclosing type"
Why?