Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does this syntax mean in the declaration of an abstract class?

Tags:

c#

I suppose that this is an easy question but I couldn't find the right answer. What means this syntax? I'm kind of confuse about the new() at the end of the line:

public abstract class SomeClass<E> : Controller where E : ISomeInterface, new()
{
    //code of the abstract class
}
like image 667
Mauro Bilotti Avatar asked Mar 10 '14 13:03

Mauro Bilotti


1 Answers

The new constraint specifies that any type argument in a generic class declaration must have a public parameterless constructor. To use the new constraint, the type cannot be abstract.

From: http://msdn.microsoft.com/en-us/library/sd2w2ew5.aspx

like image 77
Artur Gadomski Avatar answered Nov 12 '22 10:11

Artur Gadomski