ConvertToInt Method (.NET)

 

This method returns an integer that represents the specified IP address. This conversion is very handy for storing IP addresses in the most efficient format. This is a static method.

 

For example, it typically takes 12-15 characters in a database to store an IP address as a string. Yet it only takes 4 bytes to store it as an integer. That's a savings of about 10 bytes (about 70%) per database record. You may find this conversion convenient for other purposes as well.

Syntax:

 IPasInt = CountryObj.ConvertToInt(ipAsString)

The ipAsString parameter specifies the IP address to be converted to an integer.

Returns:

An integer value representing the specified IP address.

VB.NET Example:

 

Response.Write("The IP address of 207.12.14.10 converts to ")

Response.Write(CountryObj.ConvertToInt("207.12.14.10").ToString())

Response.Write(" as an integer.")

C# Example:

 

Response.Write("The IP address of 207.12.14.10 converts to ");

Response.Write(CountryObj.ConvertToInt("207.12.14.10").ToString());

Response.Write(" as an integer.");

Note: See the ch_convertIP_vb.aspx sample for more information.

 

See Also:

ConvertFromInt Method (.NET)