Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Compiler Error CS0417
Collapse the table of content
Expand the table of content

Compiler Error CS0417

'identifier': cannot provide arguments when creating an instance of a variable type

This error occurs if a call to the new operator on a type parameter has arguments. The only constructor that can be called by using the new operator on an unknown parameter type is a constructor that has no arguments. If you need to call another constructor, consider using a class type constraint or interface constraint.

The following example generates CS0417:

// CS0417
class ExampleClass<T> where T : new()
{
    // The following line causes CS0417.
    T instance1 = new T(1);   

    // The following line doesn't cause the error.
    T instance2 = new T();
}
Show:
© 2015 Microsoft