Finding The Ip Address Of You Computer On C#

  1. using System;  
  2. using System.Net; //Network Name space  
  3. class FindanIP {  
  4.     static void Main() {  
  5.         String HostName = string.Empty; //Read the Host Name.  
  6.         HostName = Dns.GetHostName();  
  7.         Console.WriteLine("Local Machine Name: " + HostName);  
  8.         IPHostEntry ipEntry = Dns.GetHostEntry(HostName); // Using this method we can get Host Name,IP address is obtained.  
  9.         IPAddress[] addr = ipEntry.AddressList;  
  10.         for (int i = 0; i < addr.Length; i++) {  
  11.             Console.WriteLine("IP Address is : " + addr[i].ToString());  
  12.         }  
  13.         Console.ReadKey();  
  14.     }  
  15. }