I want to create an object from a class, but with the restriction of the selected enum.
Example:
- Is Enum.X selected then the object may have only name.
- Is Enum.Y selected then the object may have only age.
- Is Enum.Z selected then the object may have name and age.
So far all properties are included for each object of MyObjectClass, but in the long run this leads to confusion.
You can imagine my problem like a form, where further information is requested, depending on the previous selection. With the restriction that my problem is only similar, but should solve almost the same.
public class MyObjectClass
{
public MyEnum Enum { get; set; }
public string Name { get; set; }
public string Age { get; set; }
}
How can something like this be implemented in C#?