How do I get the local machine name in C#?

后端 未结 5 881
梦谈多话
梦谈多话 2020-11-27 18:27

How do I get the local machine name?

5条回答
  •  孤独总比滥情好
    2020-11-27 19:12

    From link text

    Four ways to get your local network/machine name:

    string name = Environment.MachineName;
    string name = System.Net.Dns.GetHostName();
    string name = System.Windows.Forms.SystemInformation.ComputerName;
    string name = System.Environment.GetEnvironmentVariable("COMPUTERNAME");
    

    More information at: Difference between SystemInformation.ComputerName, Environment.MachineName, and Net.Dns.GetHostName

提交回复
热议问题