![]() |
Is 172.32.254 a valid ip address ? TryParse thinks it is.
Not sure where to post this. This might be networking or coding.
I have an ipv4 ip address that I need to validate in C#. I'm using IpAddress.Tryparse Code:
IPAddress ip = null;Can somebody explain this to me? |
It is certainly not valid.
I would report the validation of the address as a bug in the software. |
Hm, that would mean filing a bug report with Microsoft. Need to so further research first before I take that step.
Current workaround is to first split the string with the IP address and check if I get four octets back. |
I don't know anything about C# or TryParse(), but: that seems like an absurdly blatant validation failure. Not only that, it's inserting a value for you. (Maybe the documentation speaks to what happens when you pass it three octets?)
|
Quote:
Quote:
Please note, that in situations like this (unexpected behavior of system function) following approach is recommended:
|
Thanks SigTerm.
I found that link, but I never read the user comments in it (till somebody on another forum pointed me to it about 8 hours ago). In my opinion it should not be there but under remarks in the 'official' section. And this is the inet_addr link that I found on msdn. OK, solved :D PS: thanks to everybody for the replies. |
| All times are GMT -5. The time now is 02:06 AM. |