Click here to Skip to main content
11,790,613 members (64,285 online)
Click here to Skip to main content

Tagged as

Finding Computer Name Using C#

, 5 Dec 2011 CPOL 26.6K 5
Rate this:
Please Sign up or sign in to vote.
How to obtain the NetBIOS and DNS computer names of the local computer.

This C# code snippet obtains the NetBIOS and DNS computer names of the local computer.

static string GetName ()
   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;


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Technical Lead Erls Corporation
India India
I am Dinesh kumar Choudhary by Name, a software Designer and Developer by Work, a Indian Hindu by Religion, Co-Founder of DSFoundation located at by profession, a Loving husband and a Caring Father by Relation.

I have a blog Website at DSFoundation is the Autonomous body to serve for the management of Local shops located at New Delhi, India. Now a days DSFoundation and its subsidiaries are managed by Erls Corporation, an Another initiative by me and my colleagues, in which i am the another CO-Founder of the Organization. Erls Corporation can be located at

You may also be interested in...

Comments and Discussions

GeneralMy vote of 1 Pin
Daniel Fisher (lennybacon)20-Mar-14 1:38
memberDaniel Fisher (lennybacon)20-Mar-14 1:38 
GeneralReason for my vote of 5 Useful Pin
edgartaor21-Feb-12 16:21
memberedgartaor21-Feb-12 16:21 
Generalyes, a basic one but could be of use to a beginner .. Pin
Denno.Secqtinstien12-Dec-11 18:22
memberDenno.Secqtinstien12-Dec-11 18:22 
GeneralReason for my vote of 1 Too basic Pin
yuriiv12-Dec-11 16:16
memberyuriiv12-Dec-11 16:16 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.1509028.1 | Last Updated 5 Dec 2011
Article Copyright 2011 by Denno.Secqtinstien
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid