In this blog, I will demonstrate how Namespaces are used in C#
Namespaces are used in C# programming in two ways,
Namespaces are used to use or include various classes of .Net Framework. A namespace can only be applied by using "using" keyword. We can include any number of Namespaces.
Namespaces are used to use or include various classes of .Net Framework. A namespace can only be applied by using "using" keyword. We can include any number of Namespaces.
For Example, in order to use -
- Console.Write("hello Tutpoint");
We have to first define namespace as
- using System;
Here, 'System' is a namespace, 'Console' is the class of that namespace, and 'write' is the method of the console class. So, in order to use Write() method of Console class directly, we have defined the namespace. We have another way to do this as shown below,
- System.Console.Write("hello Tutpoint");
While programming, we declare our own namespaces to control the scope of class and method names. Use the 'namespace' keyword to declare a namespace. As shown in the below example, we have declared a namespace named "Tutpoint":
- using System;
- namespace Tutpoint
- {
- class Program
- {
- static void Main(string[] args)
- {
- Console.WriteLine("hello");
- }
- }
- }
Nested Namespace is defined as namespace inside a namespace. Syntax for nested namespace is shown below:
Here, 'namespace_name2 ' is a namespace inside 'namespace_name1 ' namespace.

SandyPosted Oct 7, 2017, 11:42 AM
Than what is the use of Nested Namespace? what is its advantage?
SandyPosted Oct 6, 2017, 11:48 PM
Is there is any performance or memory improvement if we create nested Namespace in a class?