There is no clearly established criterion. It is more like.
Some people prefer to always use one way or the other. Others prefer to switch depending on what is being used or even more than how often it is used. If you are going to use a name only once, it is usually easier to write it whole in the place of use instead of making an "import". But there’s a downside to the consistency.
My personal observation is that it is rare to use a fully qualified name and there is a preference for using
/import
. The use of the full name is only adopted, in most cases, when there is a conflict of names.
It is still possible to apply the using
creating an alias of its own in this way (credit for dcastro in the comments):
using WF = System.Windows.Forms.
Then you use the alias created (WF
) to disambiguate the names.
C# 6 encourages the adoption of using
a little more since now even static classes can be imported, or even static members of normal classes.
In other languages this may be different, but it seems you cared about C# and VB.NET secondarily. So ask yourself how many times have you seen someone using the first form.
More and more it will be common to use:
using System;
using static System.Console; //C# 6
void Main() {
int i = 10; //raramente se usa o tipo do .NET, prefere-se o alias da linguagem
//ou usa-se o var mesmo, neste caso
WriteLine(i); //C# 6
}
I put in the Github for future reference.
Look we usually use the whole reference because if there was System.Console.Writeline and Output.Console.Writeline and use is not known which Console to use.
– Ricardo