編譯器錯誤 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()
{
}
}