Mega Code Archive

 
Categories / C# / Network
 

IP Address To Number

using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace tera.commons.utils {     public class Functions     {          public static double IPAddressToNumber(string IPaddress)     {       if (IPaddress == "")         return 0;                int i;       string[] arrDec;       double num = 0;              arrDec = IPaddress.Split('.');       for (i = arrDec.Length - 1; i >= 0; i = i - 1)       {         num += ((int.Parse(arrDec[i]) % 256) * Math.Pow(256, (3 - i)));       }       return num;     }   } }