HomeCSharpC# 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

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

This C# program calculates and displays an upper triangular matrix based on user input. Problem Statement: The program takes the...
This C# program serves as a demonstration of bitwise operators, which are fundamental operators used for manipulating individual bits in...
This C# program is designed to interchange or swap the columns of a matrix. A matrix is a two-dimensional array...