Perf difference between importing a namespace and wrting the fully qualified name in code?

  • Thread starter Thread starter BH
  • Start date Start date
B

BH

Is there a performance difference between importing (keyword "using") a
namespace for an entire class file and using the classes from that namespace
with the fully qualified name? Particularly when only one class from the
namespace is needed once? For example:

Option 1:
.....
using System.Text;
......
StringBuilder sb = new StringBuilder();

Option 2:
.......
System.Text.StringBuilder sb = new System.Text.StringBuilder();


Thanks
Bob
 
Is there a performance difference between importing (keyword "using") a
namespace for an entire class file and using the classes from that namespace
with the fully qualified name? Particularly when only one class from the
namespace is needed once? For example:

Option 1:
....
using System.Text;
.....
StringBuilder sb = new StringBuilder();

Option 2:
......
System.Text.StringBuilder sb = new System.Text.StringBuilder();


Thanks
Bob

They are the exact same. The C# compiler compiles both to

instance void [mscorlib]System.Text.StringBuilder::.ctor()

in the Intermediate Language.

Austin Ehlers
 
Back
Top