How to use :: Namespace Alias Qualifier in C# Last Updated : 06 Mar, 2019 Comments Improve Suggest changes Like Article Like Report Namespace Alias Qualifier(::) makes the use of alias name in place of longer namespace and it provides a way to avoid ambiguous definitions of the classes. It is always positioned between two identifiers. The qualifier looks like two colons(::) with an alias name and the class name. It can be global. Thus it doesn't invoke a lookup in the aliased namespace but in the global namespace. Syntax: alias_name::class-name; Example: csharp // C# program to illustrate how to use // the :: Namespace Alias Qualifier using System; // creating aliased name using first = firstnamespace; using sec = secondnamespace; namespace Geeks { class GFG { // Main Method static void Main() { // use of Namespace alias qualifier(::) first::GFG1 obj1 = new first::GFG1(); obj1.display(); } } } // Both namespaces have a // class named GFG1 namespace firstnamespace { class GFG1 { public void display() { Console.WriteLine("It is the first namespace."); } } } namespace secondnamespace { class GFG1 { public void display() { Console.WriteLine("It is the second namespace."); } } } Output: It is the first namespace. Note: The namespace alias qualifier :: is only used for the namespaces or aliases and cannot be used for subclasses. Example: System.Collections::lists obj= new System.Collections.lists() // illegal aliasname = System.Collections; aliasname::lists obj = new aliasname::lists(); // Legal csharp // C# program to illustrate how to use // the :: Namespace Alias Qualifier using aliasname = System.Collections; namespace Geeks { class GFG { // Main Method static void Main() { // using :: Namespace Alias Qualifier aliasname::Hashtable obj = new aliasname::Hashtable(); // Add items to the table. obj.Add("ASCII value of A is:", "65"); obj.Add("ASCII value of B is:", "66"); // displaying the result foreach(string i in obj.Keys) { System.Console.WriteLine(i + " " + obj[i]); } } } } Output: ASCII value of A is: 65 ASCII value of B is: 66 Comment More infoAdvertise with us Next Article How to use :: Namespace Alias Qualifier in C# ravikishor Follow Improve Article Tags : C# Similar Reads C# | How to use Interface References In C#, you are allowed to create a reference variable of an interface type or in other words, you are allowed to create an interface reference variable. Such kind of variable can refer to any object that implements its interface. An interface reference variable only knows that methods which are decl 5 min read How to Create and Use Alias Command in Linux Imagine you're lost in a maze of complicated Linux commands. You stumble upon a secret doorway marked "Alias," and inside you find shortcuts to all your favorite commands! That's what creating aliases is like. You get to make your own mini-commands for the long ones you use all the time, making thin 6 min read How to declare namespace in JavaScript ? The coding standard of assigning scope to identifiers (names of types, functions, variables, and so on) to avoid conflicts between them is known as a namespace. It is a framework for a collection of identifiers, functions, and methods. It gives its contents a sense of direction so that they are easi 3 min read Nested Inline Namespaces In C++20 The Inline Namespace is a feature that was first introduced in C++ 11. They can also be nested inside another namespace and the members of this nested namespace can be accessed as if they are the members of the parent namespace. Their syntax may seem complex so in C++20, a new version introduced a n 2 min read How to Install a C# Class Library in Visual Studio? A C# library project is a separate project used to hold utility classes. So this might be the class that handles our database or might handle some communications with the network. In our case, we are going to create a math library that is a stand-in for some of those other cases. It is a single sour 3 min read XML Namespaces in Android In an XML file, namespaces are used to provide elements and attributes with distinctive names. Names for elements or attributes in an XML instance may come from different XML vocabularies. The ambiguity between similar elements or attributes can be eliminated if each vocabulary is given its own name 2 min read What is the use of Namespaces and Accessors in Less ? LESS (stands for Leaner Style Sheets) is a backward-compatible extension for CSS. LESS is a CSS pre-processor that provides you to customize, arrange, and utilize the style sheets for the webpage. Less is a dynamic style sheet language that can be executed on the client-side or server-side. Less com 2 min read JavaScript | Namespace Namespace refers to the programming paradigm of providing scope to the identifiers (names of types, functions, variables, etc) to prevent collisions between them. For instance, the same variable name might be required in a program in different contexts. Using namespaces in such a scenario will isola 1 min read Strict Aliasing Rule in C with Examples Aliasing: Aliasing refers to the situation where the same memory location can be accessed using different names. For Example, if a function takes two pointers A and B which have the same value, then the name A[0] aliases the name B[0] i.e., we say the pointers A and B alias each other. Below is the 4 min read C# | How to Implement Multiple Interfaces Having Same Method Name Like a class, Interface can have methods, properties, events, and indexers as its members. But interface will contain only the declaration of the members. The implementation of interface's members will be given by the class who implements the interface implicitly or explicitly. C# allows the impleme 4 min read Like