编译器错误 CS0412
更新:2007 年 11 月
错误消息
“generic”:参数或局部变量不能与方法类型参数具有相同的名称
在泛型方法的类型参数与该方法的一个局部变量或该方法的一个参数之间存在名称冲突。若要避免此错误,请重命名任何有冲突的参数或局部变量。
示例
下面的示例生成 CS0412:
// 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()
{
}
}