Types of Namespace in C#
The namespaces are used in C# that contains collection of classes. There four types of namespaces in C#.
- Directive
- Station
- Alias
- Nested
Directive Namespace:
The directive namespace that is from link library and direct as link.
Eg:
- using system.IO
- using System;
- Console.WriteLine("Hai");
- Console.WriteLine("Hello C# Corner!");
Station Namespace:
The namespace that created automatically for project.
Eg: Console app create.
- using System.Xml;
- //creating xml document automatically xml namespace will be added.
- XmlDocument objXMLDoc = new XmlDocument();
Alias Namespace:
The user defined name is created.
Eg:
- using xx system.IO;
- using System;
- using hpy = System.Text.StringBuilder; //Alias namespace
- class Program
- {
- static void Main()
- {
- hpy Happy = new hpy();
- hpy.Append("smile");
- hpy.Append(100);
- Console.WriteLine(Happy);
- }
- }
Nested Namespace:
This nested namespace hasa namespace within another namespace.
Eg.
- Namespace Humanbeing
- {
- Class male
- {
- class female
- {
- }
- }
- namespace animal
- {
- class monkey
- {
- }
- }
- }

Jaipal ReddyPosted Apr 6, 2016, 6:10 AM
Nice
Keerthi VenkatesanPosted Apr 1, 2016, 9:12 AM
good one
prashant YadavPosted Mar 31, 2016, 5:27 AM
vcbxvbxcvbx
prashant YadavPosted Mar 31, 2016, 5:10 AM
usful
prashant YadavPosted Mar 31, 2016, 4:51 AM
vbmvb vbmvb