tags:

views:

98

answers:

0

Possible Duplicate:
How to convert an IPv4 address into a integer in C#?

I'm trying to take strings that are IPv4 IP addresses and convert them to their numeric equivalents.

Is this correct?

 var segments = ipV4Address.split('.');

 var ipV4AddressAsNumber =  
  Int64.Parse(segments[0]) * 16777216 + /* octet1 * 256*256*256 + */
  Int32.Parse(segments[1]) * 65536 +    /* octet2 * 256*256     + */
  Int32.Parse(segments[2]) * 256 +      /* octet3 * 256         + */
  Int32.Parse(segments[3]);             /* octet4                 */