Global Namespace Alias, Object alias and External Alias

I wanted to show three ways how to set aliases for namespaces, objects and assemblies. Less known are the Assembly External aliases that are supported in Visual Studio.

Check the following snipped, which uses all possible aliases.

Code Snippet

    extern alias externsys;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using sys = System;
    using con = System.Console;
    namespace AliasTests
    class Program
    static void Main(string[] args)
    // Full namespace
    // Global Namespace alias
    // External alias
    // Object alias

Namespace alias is just renaming of an existing namespace to different one.

Type alias is shortcut for a type from its full name (with namespace)

External alias is an identifier of specific assembly, where is the namespace taken from. By default, there is an external alias global for all referenced assemblies.

To set external alias in Visual Studio, you need to go to Solution Navigator, select an assembly.


Extern alias walkthrough –

How to: Use the Namespace Alias Qualifier (C# Programming Guide) –

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s