string name = Environment.MachineName;
string name = System.Net.Dns.GetHostName();
string name = System.Windows.Forms.SystemInformation.ComputerName;
string name = System.Environment.GetEnvironmentVariable("COMPUTERNAME");
If you want the FQDN (fully qualified domain name) of the local computer, you can use
System.Net.Dns.GetHostEntry("localhost").HostName
The other methods will only return the local name, without any domain specific info. For instance, for the computer myComp.myDomain.com, the previous methods will return myComp, whereas the GetHostEntry method will return myComp.myDomain.com