locked
Parsing IPAdress

    Question

  • HI,

    I get an "invalid IPAdress exception" when I try to parse IPAddress entered in a textbox.

    IPAddress addr = IPAddress.Parse(text1.ToString());

    But my program works fine when I parse IPAddress as follows.

    IPAddress addr = IPAddress.Parse("128.250.23.155");

    Can anyone tell me why this is happening and how I can fix this problem?

    Thanks in advance.

     

     

     

     

     

    Monday, September 25, 2006 1:45 PM

Answers

  • hello,

    textbox.Tostring() is wrong because it return its type rather than Value by defualt.

    You need to write this :

    IPAddress address = IPAddress.Parse(textBox1.Text);

    It'll work fine.

    Cheers ;-)

    Monday, September 25, 2006 2:18 PM

All replies

  • What is text1? Maybe try with IPAddress addr = IPAddress.Parse(text1.Text);
    Monday, September 25, 2006 1:53 PM
  • hello,

    textbox.Tostring() is wrong because it return its type rather than Value by defualt.

    You need to write this :

    IPAddress address = IPAddress.Parse(textBox1.Text);

    It'll work fine.

    Cheers ;-)

    Monday, September 25, 2006 2:18 PM