Namespaces and physical coding?

Possible duplicate:
Using expressions against a namespace path? FROM#

I just want to know what the difference is between including the namespace at the top of the C # class and actually defining it in the program code.

So:

using System.Windows; 

or

 System.Windows.MessageBox.Show(); 

Will the namespace load the entire library or will only the necessary data be used?

Sorry if this may seem confusing.

0
source share
3 answers

You need to distinguish between namespaces and assemblies. They are completely different.

using directives only talk about namespaces - and two ways to access MessageBox will produce exactly the same code. Use one that prints the most readable code, which usually uses using directives and short names.

+4
source

The first is easier to read. You should promote readability. I do not think that there is any possibility of compilation or loading, and if so, I did not notice this in 500kloc projects.

+1
source

Write the full namespace directly in your statements if any identifier is ambiguous.

 using System.Windows.Forms; using System.ServiceModel.Channels; ... var msg = new Message(); // ambiguous var msg1 = new System.Windows.Forms.Message(); // OK var msg2 = new System.ServiceModel.Channels.Message(); // OK 
0
source

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


All Articles