Ask Learn
Preview
Please sign in to use this experience.
Sign inThis browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
'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();
}
.NET feedback
.NET is an open source project. Select a link to provide feedback:
Please sign in to use this experience.
Sign in