How should i implement, in C#, a class containing a property with the type of something and then that something example :
public class MyObject{ public someEnum e { get; set;} public Object ObjectDependentOnE { get; set; } }
I want to be able to return the right type for my object which depends on my enum. for example if e = 1, my object is of type T1…
or maybe I trying to do somethng wrong
any idea?
I am unsure of what you are really trying to do, but it appears that generics is what you are looking for:
You can constraint T to classes that implement a given interface.
Usage would be: