how to convert string to System.Net.IPAddress

Viewed 47956

how can i convert string to System.Net,IPAddress in C#/.net 3.5

i tried this but i got this error "Cannot convert type 'string' to 'System.Net.IPAddress'"

 public void Form1_Load(object sender, EventArgs e)
    {
        IPHostEntry host;
        string localIP = "?";
        host = Dns.GetHostEntry(Dns.GetHostName());
        foreach (IPAddress ip in File.ReadAllLines("proxy.txt"))
        {
            if (ip.AddressFamily.ToString() == "InterNetwork")
            {
                localIP = ip.ToString();
                textBox1.Text = ip.ToString();
            }
        }

   }
6 Answers
Related