How to Get Computer Name in C#/CSharp

To get computer name in C#/CSharp, we make use of Environment class and its property MachineName.  Example is given below.

using System;


namespace Hello_World
{

    class Program
    {
        static void Main(string[] args)
        {            
            Console.WriteLine(Environment.MachineName);
        }
    }
}