I need to create properties dynamically.
My scenario is like this:
I have many classes that derive from BaseClass.
BaseClass has a dictionary where inherited classes should define stuff. Those definitions are done like this.
public string Type
{
get
{
return dictionary["type"];
}
set
{
dictionary["type"] = value;
}
}
I will have many inherited methods like this in my derived classes, where the name of the property is almost identical to the key that references its corresponding value in the dictionary. So my idea is to add attributes in the derived classes, starting with an underscore, to distinguish them and use them to create those properties.
- How would I define dynamically those properties at run-time?
- Is it possible to define those at compile-time? Would it make sense to do so?