Search code examples
c#inet-aton

Are there any .NET Framework Method that does INET_ATON()


That does this calculation below

address = '174.36.207.186'

( o1, o2, o3, o4 ) = address.split('.')

integer_ip =   ( 16777216 * o1 )
             + (    65536 * o2 )
             + (      256 * o3 )
             +              o4

Solution

  • string s = "174.36.207.186";
    
    uint i = s.Split('.')
              .Select(uint.Parse)
              .Aggregate((a, b) => a * 256 + b);