Trouble checking dynamic entity
Greetings,
A old colleague of mine made this code:
public abstract class PagedViewModelBase<T> : PartnerViewModelBase, IPagedCollectionView where T : Entity, IEditableObject, new()
Now I want to check what the type/value is of T.. I've tried using "T is Model
but it gives me the er开发者_开发百科ror "'T' is a 'type parameter' but is used like a 'variable'".
How can I check if "T" is of a particular model ?
You could try the following check
typeof(T) == typeof(Model)
In most cases you can check it with this code
typeof(Model).IsAssignableFrom(typeof(T));
精彩评论