Nice find...that DOES look a whole lot like my pain :-)
What I do know, however, is that if someone ever called me and I asked them
for their IP address, and they told me "10.1.176", I would say "That is not a
valid IP address."
More so if someone said "65536"...
I guess the real answer, then, is to do the following logic:
string ipString = "10.1.176";
if (IPAddress.TryParse(ipString))
{
IPAddress ip = IPAddress.Parse(ipString);
if (ip.ToString() != ipString)
// Not Valid
else
// Valid
}
That look about right? Seems silly, but works...
Thanks,...J.~
> >All,
> >
[quoted text clipped - 62 lines]
>
> -----------------------------------------------------------------------------------------------------------------------------------------------------------------------
Ben Voigt - 03 Nov 2006 15:14 GMT
> Nice find...that DOES look a whole lot like my pain :-)
>
[quoted text clipped - 19 lines]
>
> That look about right? Seems silly, but works...
It'll reject leading zeros which aren't actually invalid.
Maybe IPAddress.TryParse(ipString) && ipString.Split(new Char[] {
'.' }).Length == 4?
> Thanks,...J.~
>
[quoted text clipped - 73 lines]
>>
>> -----------------------------------------------------------------------------------------------------------------------------------------------------------------------