The source code to get the Machine Name or Host Name using Environment class is given below. The given program is compiled and executed successfully.
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 . . .
Program:
The source code to get the Machine Name or Host Name using Environment class is given below. The given program is compiled and executed successfully.
Output: