

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- 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
- Related Questions & Answers
- C++ Scope resolution operator
- Scope resolution operator in C++
- What is the use of scope resolution operator in C++?
- PHP Scope Resolution Operator (::)
- Why does C++ need the scope resolution operator?
- Scope Resolution Operator Versus this pointer in C++?
- Scope Resolution Operator vs this pointer in C++
- Where do we use scope Resolution Operator (::) in C#?
- What is the ?-->? operator in C++?
- What is the operator precedence in C#?
- What is the scope of variables in JavaScript
- What is Representing Scope Information?
- What is the Resolution of our Eyes in Megapixels?
- What is a Ternary operator/conditional operator in C#?
- What is sizeof operator in C++?
Advertisements