Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

does 'using' provide any advantages?

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

like image 258
Brap Avatar asked Aug 28 '26 21:08

Brap


1 Answers

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.

like image 69
Tomas Petricek Avatar answered Aug 31 '26 12:08

Tomas Petricek