編譯器警告 (層級 2) CS0435
更新:2007 年 11 月
錯誤訊息
'assembly' 中的命名空間 'namespace' 與 'assembly' 中的匯入型別 'type' 衝突。請使用在 'assembly' 中定義的命名空。
當原始程式檔 (file_2) 中的命名空間與 file_1 中的匯入型別衝突時,便會發出這個警告。編譯器使用原始程式檔中的型別。
下列範例會產生 CS0435:
請先編譯這個檔案:
// CS0435_1.cs
// compile with: /t:library
public class Util
{
public class A { }
}
然後再編譯這個檔案:
// CS0435_2.cs
// compile with: /r:CS0435_1.dll
using System;
namespace Util
{
public class A { }
}
public class Test
{
public static void Main()
{
Console.WriteLine(typeof(Util.A)); // CS0435
}
}