Have problems when two of the referenced assemblies define type A.A1

If two assemblies define namespace Aone containing class A1, then two classes are considered unique types.

a) Are these namespaces also unique?

b) If there program Pis a link to both assemblies, how do we create instances of two types? Namely, I keep getting an error when I try to create an instanceA.A1

using A;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            A1 a = new A1(); // error
        }
  }
}

c) But if it program Palso defines type B.A1, then the compiler does not complain when I declare an instance A1:

using A;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            A1 a = new A1(); // ok
        }
    }

    class A1 { }
}

The ifnt compiler does not compile, since it does not know which version to A1use ( A.A1from one of the referenced assemblies or B.A1)?

thank

+3
2
+5

, , no-no (.. !). , , , / .

+1

Source: https://habr.com/ru/post/1755135/


All Articles