Reputation: 1437
I was searching for reusable Grid for MVC .Net. I found one open source Grid.
In the code I found a pretty interesting class declaration which I didn't understand . Can anybody tell me a detailed description of class declaration below:
public class Grid<TEntity, TSearchForm> : IGrid where TSearchForm : SearchForm, new()
{
}
Also how do I create an instance of this class?
Upvotes: 3
Views: 1348
Reputation: 3553
This is generic class inherited from IGrid with two parameters: TEntity, TSearchForm.
Also there is a constraint on type of TSearchForm:
it must be of type SearchForm or below it in hierarchy (able to cast to SearchForm implicitly)
TSearchForm must have public parameterless constructor.
More info:
where (generic type constraint new Constraint
Upvotes: 6
Reputation: 499362
The class is a generic class, it implements IGrid
.
The two generic type parameters are TEntity
and TSearchForm
.
TSearchForm
is constrained to be SearchForm
or a type that inherits from SearchForm
and that it has a default constructor.
Suggested reading:
Upvotes: 5
Reputation: 2700
Upvotes: 6