namespace A
{
class B
{
}
class A
{
public void f()
{
A.B var = new A.B();
}
}
}
Run Code Online (Sandbox Code Playgroud)
使用 msvc 2019 和 .net core 3.1 编译,此代码示例给出以下错误:
Error CS0426 The type name 'B' does not exist in the type 'A'
Run Code Online (Sandbox Code Playgroud)
我知道最好不要为类和命名空间提供相同的名称。但是有没有办法解决这种碰撞?