How to get Either net card IP address of my pc

  • Thread starter Thread starter Sudip_inn
  • Start date Start date
S

Sudip_inn

Guest
when i am testing below code which is showing my VMWare IP address but how to get my either net card IP address.

public static string GetIPAddress()
{

var host = Dns.GetHostEntry(Dns.GetHostName());
foreach (var ip in host.AddressList)
{
if (ip.AddressFamily == AddressFamily.InterNetwork)
{
return ip.ToString();
}
}

throw new Exception("No network adapters with an IPv4 address in the system!");
}
how to fetch either net card or my network lan card IP address by c#. thanks

Continue reading...
 
Back
Top