c# - Intresting behaviour of IPAddress.TryParse -


i'm using ipaddress.tryparse validate ip address, if use

if (ipaddress.tryparse("192.168.1.009", out ip) 

it fails, but

if (ipaddress.tryparse("192.168.1.007", out ip) 

passes. if last digit 8 or 9 fails on valid ip address.

i'm not sure work?

quick guess:

009 , 007 interpreted octal numbers, whereas 007 valid number in base-8 , 009 not.

try if (ipaddress.tryparse("192.168.1.9", out ip)) instead.


Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -