Types of Namespace in C#

Dec 30, 2016C#
Summarize with AI: Google AI Claude ChatGPT Perplexity Grok

AI links open with a title + excerpt (these tools can't fetch the page themselves) — use "Copy full article" to paste the complete text for a fuller summary.

Share:

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); } } <\pre>

Nested Namespace: This nested namespace hasa  namespace within another namespace. Eg:

Namespace Humanbeing { Class male { class female { } } namespace animal { class monkey { } } }

#C#

Comments

Be the first to comment.

Leave a comment

Never shown publicly.

Comments are reviewed before appearing publicly.