Answers for "c# get pc ip ipv4"

C#
12

get current computer ipv4 C#

public static string GetLocalIPAddress()
{
    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!");
}
Posted by: Guest on June-25-2020

C# Answers by Framework

Browse Popular Code Answers by Language