Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / C#

alias: practical reference

alias: practical reference: alias is a contextual keyword only immediately after extern in extern alias; an ordinary using alias places an identifier before = and does not use the alias keyword.

Version: C# language and .NET 10 reference runtime

Syntax

alias /* grammar-specific form */

alias is a contextual keyword only immediately after extern in extern alias; an ordinary using alias places an identifier before = and does not use the alias keyword.

Use it to resolve name conflicts and shorten complex types.

An alias does not inherit and does not change runtime identity.

Alias scope is limited to the compilation unit or namespace; extern alias requires reference configuration.

The complete program actually uses alias; its exact expected stdout is String.

Examples

extern alias AliasDemo;
using System;

Console.WriteLine(typeof(AliasDemo::System.String).Name);

Result

String

The complete program actually uses `alias`; its exact expected stdout is `String`.

Sources