C# Programming/Keywords/alias
Cover | Introduction | Basics | Classes | Advanced Topics | The .NET Framework | Index
You can help to develop the work, or you can ask for assistance in the project room.
The alias
keyword is used to indicate an external alias.
When you need to use several versions of the same assembly or assemblies with the same full qualified typenames, you need to use the alias
and extern
keywords to give different alias names for each version.
Example:
externaliasAppTools; externaliasAppToolsV2;
To use the typenames of each version, you have the operator ::
.
Example:
AppTools::MainTooltool_v1=newAppTools::MainTool(); AppToolsV2::MainTooltool_v2=newAppToolsV2::MainTool();
However, this only says to the compiler that there are several assemblies with typename conflicts. To relate what of each assemblies match's the alias name, you have to tell the compiler on its options apart the source. On dotNet
command line, this options would be:
/r:AppTools=AppToolsv100.dll /r:AppToolsV2=AppToolsv200.dll
Notice:
In order for it to be of use, you need to provide an external assembly to the compiler (e.g. pass /r:EXTALIAS=XXX.dll
) and identify the external alias within the code (e.g. extern alias EXTALIAS;
)
C# Keywords |
---|
Special C# Identifiers (Contextual Keywords) |
Contextual Keywords (Used in Queries) |