Exclude class from used namespace

The first instruction of all my C # files is " using System; ". Now with wireframe version 4, this namespace contains a class called Action. This is also the class name for my own code in the regularly used namespace. Now there is, of course, a conflict. Of course, I can resolve this conflict using the explicit "MyNamespace.Action", where I used to use the "Action". This is a few hundred, if not thousands of lines. Or I could not use the System namespace, which of course leads to many other problems. I would like to write something like "using System, but not System.Action", but I cannot find instructions for this. Any ideas?

+4
source share
2 answers

No, you canโ€™t.

But you can add using Action = MyNamespace.Action . This will be very confusing for new developers, although since Action is a fundamental part of .net with 3.5, I highly recommend that you rename your class.

+7
source

The using directive has two uses:

To allow the use of types in a namespace, so you do not need to qualify the use of a type in this namespace:

 using System.Text; 

To create an alias for a namespace or type (you can go for this).

 using Project = PC.MyCompany.Project; 

The using keyword is also used to create using statements that determine when an object will be deleted. For more information, see Using Statement.

http://msdn.microsoft.com/en-us/library/dd264736.aspx

+1
source

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


All Articles