C# Error CS0694 – Type parameter ‘{0}’ has the same name as the containing type, or method

C# Error

CS0694 – Type parameter ‘{0}’ has the same name as the containing type, or method

Reason for the Error & Solution

Type parameter ‘identifier’ has the same name as the containing type, or method

You must use a different name for the type parameter since the type parameter’s name cannot be identical to the type or method name that contains the type parameter.

Example 1

The following sample generates CS0694.

// CS0694.cs  
// compile with: /target:library  
class C<C> {}   // CS0694  

Example 2

In addition to the above case involving a generic class, this error may occur with a method:

// CS0694_2.cs  
// compile with: /target:library  
class A  
{  
   public void F<F>(F arg);   // CS0694  
}  

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...