- Back to Home »
- C#.NET »
- Namespaces
Posted by :
Sudhir Chekuri
Wednesday, 30 December 2015
Namespaces are the way to organize .NET code into a logical grouping according to their functionality and usability.
using is the keyword used to import namespaces.
In .NET base class libraries contains collection of namespaces.
Every namespace contains a set of classes and sub namespaces.
Namespace inside a namespace is known as sub namespace.
Example:
using System;
using System.Data;
Explanation:
System is the namespaces added at the top of the program to use classes inside it in the program.
Data is the sub namespace inside System namespace.
Hierarchy of writing program
Namespace
{
Class
{
Method
{
Code
}
}
}
Example:
Program 1:
namespace project
{
class Sample
{
static void Main()
{
System.Console.Write("hello world");
}
}
}
using is the keyword used to import namespaces.
In .NET base class libraries contains collection of namespaces.
Every namespace contains a set of classes and sub namespaces.
Namespace inside a namespace is known as sub namespace.
Example:
using System;
using System.Data;
Explanation:
System is the namespaces added at the top of the program to use classes inside it in the program.
Data is the sub namespace inside System namespace.
Hierarchy of writing program
Namespace
{
Class
{
Method
{
Code
}
}
}
Example:
Program 1:
namespace project
{
class Sample
{
static void Main()
{
System.Console.Write("hello world");
}
}
}