Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

c# convert address to int

public static uint ConvertFromIpAddressToInteger(string ipAddress)
{
    var address = IPAddress.Parse(ipAddress);
    byte[] bytes = address.GetAddressBytes();

    // flip big-endian(network order) to little-endian
    if (BitConverter.IsLittleEndian)
    {
        Array.Reverse(bytes);
    }

    return BitConverter.ToUInt32(bytes, 0);
}

public static string ConvertFromIntegerToIpAddress(uint ipAddress)
{
    byte[] bytes = BitConverter.GetBytes(ipAddress);

    // flip little-endian to big-endian(network order)
    if (BitConverter.IsLittleEndian)
    {
        Array.Reverse(bytes);
    }

    return new IPAddress(bytes).ToString();
}
Comment

PREVIOUS NEXT
Code Example
Csharp :: OIUJHKJHSKAL::KSAJ 
Csharp :: mpeg get video size 
Csharp :: c# propertyinfo indexof 
Csharp :: c# break file into words 
Csharp :: how long dose it take for formate a currupt USB? 
Csharp :: take the last 50 from array c# 
Csharp :: using Tls12 .net 3.5 
Csharp :: C# check control type 
Csharp :: c# order of initialization 
Csharp :: convert relative path to physical path c# 
Csharp :: c# array of class objects initialization with constructor 
Csharp :: lambda not null c# 
Csharp :: Count Possible Decodings 
Csharp :: how to assign rds CAL for users 
Csharp :: händelsereportage 
Csharp :: c# .net core kendo dropdownlistfor enum 
Csharp :: unity generate random offset position around a gameobject 
Csharp :: get path revit link unloaded 
Csharp :: c# variables 
Csharp :: activeNetworkInfo depricated 
Csharp :: unity prefab button not working 
Csharp :: count split elements .net 
Csharp :: c# how to output array 
Csharp :: c# initialize event 
Csharp :: unity convert pixels to units 
Csharp :: Enviar correos en C# con MailKit 
Csharp :: remove language folders build visual studio 
Csharp :: ArgumentOutOfRangeException when sorting a DataGridView using a custom IComparer 
Csharp :: material.icons for wpf 
Csharp :: Connect To MongoDB From A Different Machine 
ADD CONTENT
Topic
Content
Source link
Name
1+1 =