C# Error CS7003 – Unexpected use of an unbound generic name

C# Error

CS7003 – Unexpected use of an unbound generic name

Reason for the Error & Solution

Unexpected use of an unbound generic name

This error occurs if you use a generic type needing one parameter type without passing any generic parameter type name between the angle brackets. This use may be a variable declaration, or an object instantiation.

To correct this error

Provide one parameter type name in angle brackets when using a generic type.

Example

The following example generates CS7003:

// CS7003.cs
class Program
{
    static void Main(string[] args)
    {
        var myVar1 = new MyGenericClass<>();  //CS7003

        MyGenericClass<> var2;                //CS7003
    }
}

public class MyGenericClass<T> { }

Leave A Reply

Your email address will not be published. Required fields are marked *

You May Also Like

C# Compiler Error CS0442 – ‘Property’: abstract properties cannot have private accessors Reason for the Error You’ll get this error...
This is a really simple one . Below is a simple example of an enum called “Designation” defined with the...
This blog post explain the usage of the Checked Block in .NET and how you can use them in Visual...