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

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
 
A

Austin Ehlers

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top