Reputation: 2747
When you reference certain methods, you can either use using
or explicitly type in the entire namespace. Are there any speed advantages of using one method over the other, or is it simply there to make typing out the entire namespace easier? thanks
Upvotes: 3
Views: 428
Reputation: 3677
Are we all forgetting about extension methods? They cannot be pulled into scope without a using
namespace directive, as far as I know.
Upvotes: 0
Reputation: 243051
There is no difference at runtime.
In the .NET meta-data, a type is always represented using a full name that includes the namespace, so the using
directive known from C# will disappear when a program is compiled.
There are some subtle aspects (at compile time) when it comes to writing the using
inside or outside of a namespace
(see for example this question), but that's also only a compile-time issue.
Upvotes: 6
Reputation: 113242
It's purely a syntactic matter and is compiled to the same thing. Take a look at the IL produced by each.
Upvotes: 3