I’m wanting to create a generic lookup method to where you specify a type of object and some other identifying parameters and the method returns an object of that type. Is this possible?
I’m thinking something like this.
public T GetObjectOfType(Guid ID, typeof(T Class))
{
//lookup this object and return it as type safe
}
I know this just won’t work but i hope it explains the concept
You can use a generic method for this:
If all you want is create an instance of a specific type you do not need the additional id parameter, I assume you want to set some properties etc. based on the id. Also your class must provide a default constructor, hence the
new()constraint.