C# FAQ: How use an alias for a class or namespace
Microsoft .NET Framework, ASP.NET, Visual C# (CSharp, C Sharp, C-Sharp) Developer Training, Visual Studio
| CSharp-Online.NET:FAQs |
| edit |
[edit]
How use an alias for a class or namespace?
The using directive can be used to create an alias for a long class name or a namespace. Then, the alias can be used instead—anywhere the class name or namespace could normally appear.
The using alias is scoped within the namespace in which it is declared. The following is an example of a using alias:
// Namespace alias example using activation = System.Runtime.Remoting.Activation; // Class name alias example using arrayList = System.Collections.ArrayList; // use the aliases ... arrayList aList = new arrayList(); // creates an ArrayList activation.UrlAttribute urlAttribute; // is equivalent to ... // System.Runtime.Remoting.Activation.UrlAttribute urlAttribute;
[edit]
See also
- How use an alias for a class or namespace?
- What is a namespace?
- What is a type alias?
- ECMA-334: 16.3 Extern alias directives
- ECMA-334: 16.4 Using directives
- ECMA-334: 16.7 Qualified alias member