Compiler Error CS0412
'generic': a parameter or local variable cannot have the same name as a method type parameter
There is a name conflict between the type parameter of a generic method and a local variable in the method or one of the method's parameters. To avoid this error, rename any conflicting parameters or local variables.
The following sample generates CS0412:
C#
// CS0412.cs
using System;
class C
{
// Parameter name is the same as method type parameter name
public void G<T>(int T) // CS0412
{
}
public void F<T>()
{
// Method local variable name is the same as method type
// parameter name
double T = 0.0; // CS0412
Console.WriteLine(T);
}
public static void Main()
{
}
}
Collaborate with us on GitHub
The source for this content can be found on GitHub, where you can also create and review issues and pull requests. For more information, see our contributor guide.
.NET feedback
.NET is an open source project. Select a link to provide feedback: