Get NetBIOS and DNS computer names
Microsoft .NET Framework, ASP.NET, Visual C# (CSharp, C Sharp, C-Sharp) Developer Training, Visual Studio
| C# Code Snippets |
| See also |
| edit |
This C# code snippet obtains the NetBIOS and DNS computer names of the local computer.
static string GetLocalHostName () { string netBiosName = System.Environment.MachineName; //return netBiosName; // Following method is deprecated // string dnsName = // System.Net.Dns.GetHostByName("LocalHost").HostName; string dnsName = System.Net.Dns.GetHostName(); return dnsName; }
[edit]
Visual C# Best Practices
Avoid using pointers in unsafe code to access Windows data.