IP address using c#

How can I easily get the IP address of my computer using c#??
Who is Participating?
Tapan PattanaikConnect With a Mentor Senior EngineerCommented:
hi Wanting2LearnMan,

                Check these useful links to get your IP address

Get the IP address in a Windows application:


C# How To Get Computer IP Address IPHostEntry:


Check Local IP Address [C#]:



For checking:

alexey_gusevConnect With a Mentor Commented:
do you mean "my computer connected via ActiveSync" ?
anyway, try to use "ppp_peer" as ServerIP and do like here:

            IPHostEntry nameToIpAddress = Dns.GetHostEntry(ServerIP);
            if ((nameToIpAddress.AddressList.Length > 0 &&
                || m_ServerPort == 0)
            IPEndPoint serverEndPoint = new IPEndPoint(nameToIpAddress.AddressList[0], m_ServerPort);
            Log.Info("Server address: " + serverEndPoint.ToString());

Wanting2LearnManAuthor Commented:
Thanks for the links and help.

I have a wireless router connected to my computer setup as an access point.

I normally go into the dos command and type ipconfig to see my ip address e.g.

I just want to get this ip and display it in a text box on my c# windows app.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.