VictorySaber
VictorySaber

Reputation: 3164

When to resolve by "using" declaration and when to explicitly state the namespace

I am using System.Configuration.ConfigurationManager only once in my entire code, and I'm wondering if it is better practice to name it explicitly rather than use a 'using' declaration.

string LogoUrl = System.Configuration.ConfigurationManager.AppSettings["LogoURL"];

and

using System.Configuration;;
string LogoUrl = ConfigurationManager.AppSettings["LogoURL"];

Does having the 'using' declaration involve more overhead than explicitly stating the namespace e.g. does it pull in more than I need?

Upvotes: 0

Views: 38

Answers (1)

Sargis Koshkaryan
Sargis Koshkaryan

Reputation: 1030

No, it doesn't.

The compiler converts all calls to a class to use the fully qualified name You can see it in the produced IL, using any decompiler.

Upvotes: 3

Related Questions