Posted By

jx_boi on 09/06/10


Tagged

ip


Versions (?)

Who likes this?

3 people have marked this snippet as a favorite

galofre
Tyster
ovuncgursoy


Get My IP


 / Published in: C#
 

  1. private string GetMyIP()
  2. {
  3. IPHostEntry host = Dns.GetHostEntry(Dns.GetHostName());
  4. foreach (IPAddress ip in host.AddressList)
  5. {
  6. if (ip.AddressFamily == AddressFamily.InterNetwork)
  7. {
  8. return ip.ToString();
  9. }
  10. }
  11. return null;
  12. }

Report this snippet  

You need to login to post a comment.