bwall
bwall

Reputation: 1060

IP parsing results in an odd value

On my computer, the following line:

System.Net.IPAddress result = default(System.Net.IPAddress);
bool success = System.Net.IPAddress.TryParse("234.34.034.004", out result);

creates the following results

  1. success evaluates to true
  2. The IP Address result returned is 234.34.28.4

What is happening?

Upvotes: 1

Views: 23

Answers (1)

robsiemb
robsiemb

Reputation: 6354

It appears that the "34" is being interpreted as octal because it has a leading zero. (The 4 probably also is being interpreted as octal, but its representation is the same in both bases).

34 in octal is 28 in decimal, thus the output.

Upvotes: 1

Related Questions