开发者

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));

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜