How to Find the IP Addresses of the Local Computer in C#
The program below shows how to retrieve all IP addresses of the local machine.
using System; using System.Net; class Test { public static void Main() { IPAddress[] a = Dns.GetHostByName(Dns.GetHostName()).AddressList; for (int i=0; i<a.Length; i++) Console.WriteLine ("IpAddr[{0}]={1}",i,a[i]); } }
Author: Christian d'Heureuse (www.source-code.biz, www.inventec.ch/chdh)
License: Free / LGPL
Index