C# Namespaces - c# - c# tutorial - c# net
C# Namespaces
What is the use of namespace in C# ?
- Namespaces in C# are used to organize too many classes so that it can be easy to handle the application.
- In a simple C# program, we use System.Console where System is the namespace and Console is the class.
- To access the class of a namespace, we need to use namespacename.classname. We can use using keyword so that we don't have to use complete name all the time.
- In C#, global namespace is the root namespace.
- The global::System will always refer to the namespace "System" of .Net Framework.
What is the use of namespace in C#
Namespace
C# namespace example
- Let's see a simple example of namespace which contains one class "Program".
C# examples - Output :
C# namespace example: by fully qualified name
- Let's see another example of namespace in C# where one namespace program accesses another namespace program.
C# examples - Output :
C# namespace example: by using keyword
- Let's see another example of namespace where we are using "using" keyword so that we don't have to use complete name for accessing a namespace program.