Get Local Computer Name in C#

2011-01-20


Here we got 4 ways to get local computer name:

1: string name = Environment.MachineName;

2: string name = System.Net.Dns.GetHostName();

3: string name = System.Windows.Forms.SystemInformation.ComputerName;

4: string name = System.Environment.GetEnvironmentVariable("COMPUTERNAME");