C# Namespace

C# Provides Concept of namespacing to organize your classes in a good manner. It makes the application easy to handle. It is like packaging of java. The System is a namespace which is used in merely every Console application. It provides methods for writing and reading from console. We can use 'using' keyword to avoid the use of fully qualified name to use a particular method present in a specific namespace. Let's see an example of C# Namespace.

using System; 
namespace first
{
            public class Example
            {
                        public int x=Convert.ToInt32(Console.ReadLine());
                        public static void Main(string[] args)
                        {
                                    Example e=new Example();
                                    Console.WriteLine("You Entered :"+e.x);
                        }
            }
}
C# Namespace Example: using fully qualified name
using System; 
namespace first
{
            public class Example1
            {
                        public int x=Convert.ToInt32(Console.ReadLine());
            }
}
namespace second
{
            public class Example2
            {
                        public static void Main (string[] args)
                        {
                                    first.Example1 e=new first.Example1();
                                    Console.WriteLine("Inside second namespace");
                                    Console.WriteLine("You entered "+e.x);
                        }
            }
}
Output
123
Inside second namespace
You entered 123  
C# Namespace Example: using keyword
using System;
using first;
namespace first
{
            public class Example1
            {
                        public int x=Convert.ToInt32(Console.ReadLine());
            }
}
namespace second
{
            public class Example2
            {
                        public static void Main (string[] args)
                        {
                                    Example1 e=new Example1();
                                    Console.WriteLine("Inside second namespace");
                                    Console.WriteLine("You entered "+e.x);
                        }
            }
}
Output
123
Inside second namespace
You entered 123