- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Where do we use scope Resolution Operator (::) in C#?
In C++ the scope resolution operator i.e. :: is used for global variables, whereas in C# it is related to namespaces.
If you have a type that share an identifier in different namespace, then to identify them use the scope resolution operator.
For example, to reference System.Console class, use the global namespace alias with the scope resolution operator −
global::System.Console
Let us see an example −
Example
using myAlias = System.Collections; namespace Program { class Demo { static void Main() { myAlias::Hashtable h = new myAlias::Hashtable(); h.Add("M", "1"); h.Add("N", "2"); h.Add("O", "3"); h.Add("P", "4"); foreach (string n in h.Keys) { global::System.Console.WriteLine(n + " " + h[n]); } } } }
Output
N 2 O 3 M 1 P 4
- Related Articles
- C++ Scope resolution operator
- Scope resolution operator in C++
- What is the use of scope resolution operator in C++?
- PHP Scope Resolution Operator (::)
- What is the scope resolution operator in C#?
- Scope Resolution Operator Versus this pointer in C++?
- Scope Resolution Operator vs this pointer in C++
- Why does C++ need the scope resolution operator?
- Why do we use comma operator in C#?
- Where do we use jQuery.noConflict() method?
- Where do we use $.extend() method in jQuery?
- How do we use equivalence (“equality”) operator in Python classes?
- How do I use the conditional operator in C/C++?
- Why do we use modifiers in C/C++?
- Why do we use extern "C" in C++ code?

Advertisements