C# program to get the Machine Name or Host Name using Environment class
using System;
class Sample
{
//Entry point of Program
static public void Main()
{
string machineName = Environment.MachineName;
Console.WriteLine("Machine Name:");
Console.WriteLine(machineName);
}
}
Output
Machine Name:
NIDHI-PC
Press any key to continue . . .
Table of Contents