C# Program to Get the Machine Name or Host Name Using Environment Class

You are currently viewing C# Program to Get the Machine Name or Host Name Using Environment Class

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 . . .

Ranjith Kumar

Hi, I'm Ranjith a full-time Blogger, YouTuber, Affiliate Marketer, & founder of Coding Diksha. Here, I post about programming to help developers.

Leave a Reply