Ok, let me explain:
Whenever you start a class in .Net and let’s say you have another project you’ve developed referenced which has non static class(es) you need to use…
You have 2 options (That I know of)
Place a using at the top of your class meaning you won’t need to explicitly name the whole project each time you need it’s classes
using FooBarProj;
public FooBar MyMethod()
{
FooBar fb = new FooBar();
//Do stuff
return fb;
}
Or do explicitly implement those:
public FooBarProj.FooBar MyMethod()
{
FooBarProj.FooBar fb = new FooBarProj.FooBar();
//Do stuff
return fb;
}
Does this make an effective difference at all? either efficiency at execution, compiling, whatever? or its simply a dev convenience issue?
It makes no difference after compiling the code.
Either using an
usingstatement, or using the whole class namespace and name, is the same thing after all.When compiling to CIL code, references to types are a single thing, each reference contains all the information, regardless of how you coded that reference.
Referencing a class with a different name
You can even rename a class if you whant, doing this:
Now you can refer to
System.Stringusing the nameTheStringin your code.All of these produces the same compiled code
stringSystem.StringString(if you placeusing System;at the beginning)TheString(if you placeusing TheString = System.String;at the beginning)Conclusion: All
usingstatements are just convenience.