Question

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 error "'T' is a 'type parameter' but is used like a 'variable'".

How can I check if "T" is of a particular model ?

Was it helpful?

Solution

You could try the following check

typeof(T) == typeof(Model)

OTHER TIPS

In most cases you can check it with this code


typeof(Model).IsAssignableFrom(typeof(T));

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top