C# Program to Implement Namespaces
Posted by Superadmin on August 15 2022 07:57:28

C# Program to Implement Namespaces

 

 

This is a C# Program to implement namespaces.

Problem Description

This C# Program Implements Namespaces.

Problem Solution

Here namespaces are used to logically arrange classes, structs, interfaces, enums and delegates and keyword namespace is required to create a user defined name space.

Program/Source Code

Here is source code of the C# Program to Implement Namespaces. The C# program is successfully compiled and executed with Microsoft Visual Studio. The program output is also shown below.

/*
 * C# Program to Implement Namespaces
 */
using System;
namespace Sanfoundry.Csharp.Codes
{
    class TestClass
    {
        public TestClass()
        {
            Console.WriteLine("Class to Demonstrate Namespace");
        }
    }
}
class MyClient
{
    public static void Main()
    {
      Sanfoundry.Csharp.Codes.TestClass mc = new Sanfoundry.Csharp.Codes.TestClass();
      Console.ReadLine();
    }
}
Program Explanation

This C# Program is used to Implement Namespaces. Here the namespaces are used to logically arrange classes, structs, interfaces, enums and delegates and keyword namespace is required to create a user defined name space.

 
Runtime Test Cases
 
Class to Demonstrate Namespace