Sponsored Ad

Sunday, May 6, 2012

Write Two Nested Namespaces in C#

You can write the nested namespaces in C#. The nested namespaces provide more facility to organize your classes and code. This program is a example of nested namespace and creating an object of class and using the class level variable.

Write Two Nested Namespaces in C#

using System;

namespace ConsoleHub
{
    namespace Innner_NameSpace
    {
        class Programs
        {
            int ClassVar = 1;
            static void Main(string[] args)
            {
                ConsoleHub.Innner_NameSpace.Programs ObjPrograms = new ConsoleHub.Innner_NameSpace.Programs();
                ObjPrograms.ClassVar = 5;

                Console.WriteLine("The value of Class Variable is {0}", ObjPrograms.ClassVar);

                Console.ReadLine();

            }
        }
    }
}

No comments:

Post a Comment

Sponsored Ad

Development Updates