Compiler Error CS0433
类型 TypeName1 同时存在于 TypeName2 和 TypeName3 中。
// CS0433_1.cs
// compile with: /target:library
namespace TypeBindConflicts
{
public class AggPubImpAggPubImp {}
}
// CS0433_2.cs
// compile with: /target:library
namespace TypeBindConflicts
{
public class AggPubImpAggPubImp {}
}
// CS0433_3.cs
// compile with: /reference:cs0433_1.dll /reference:cs0433_2.dll
using TypeBindConflicts;
public class Test
{
public static void Main()
{
AggPubImpAggPubImp n6 = new AggPubImpAggPubImp(); // CS0433
}
}
下面的示例演示如何使用 /reference 编译器选项的别名功能来解决此 CS0433 错误。
// CS0433_4.cs
// compile with: /reference:cs0433_1.dll /reference:TypeBindConflicts=cs0433_2.dll
using TypeBindConflicts;
public class Test
{
public static void Main()
{
AggPubImpAggPubImp n6 = new AggPubImpAggPubImp();
}
}