![Trending Articles on Technical and Non Technical topics](/images/trending_categories.jpeg)
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
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
What is the scope resolution operator in C#?
The scope resolution operator in C# has a different meaning as compared with C++. In C++ the :: 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
Example
using myAlias = System.Collections; namespace Program { class Demo { static void Main() { myAlias::Hashtable h = new myAlias::Hashtable(); h.Add("Q", "1"); h.Add("R", "2"); h.Add("S", "3"); h.Add("T", "4"); h.Add("U", "5"); foreach (string n in h.Keys) { global::System.Console.WriteLine(n + " " + h[n]); } } } }
Output
T 4 R 2 S 3 U 5 Q 1
Advertisements