C# Finding the Computer Name

In C#, the MachineName property of the Environment class is used to find the name of the computer on which the program is running.

Below is a sample code for usage.

namespace ConsoleApplicationTest
{
    class Program {

        static void Main(string[] args) {

            string cName = System.Environment.MachineName;

            Console.WriteLine(cName);
            Console.ReadLine();

        }
    }
}



You May Interest

C# Finding the Path to My Documents Folder

How to Find the Name of the Operating System in C# ?

C# How To Find The Average Of 10 Numbers Using A While Loop

Finding the Index Order of a Character in a String in C#

C# Finding Tangent of an Angle