tags:

views:

250

answers:

4

Any C#/.Net equivalent methods, or managed code examples for INET_NTOA and INET_ATON?

+1  A: 

Just to clarify, you're looking to parse a string representation of an IP Address, to an IPAddress object?

(That's my understanding of this article explaining INET_NTOA)

In that case ,it's System.Net.IPAddress.Parse("127.0.0.1"), and you can use the .ToString() off an IPAddress to get the string rep back out.

Will Hughes
+2  A: 

The IPAddress class has static methods:

HostToNetworkOrder
NetworkToHostOrder

With various overloads.

Richard
A: 

To make NTOA compatible with MySQL i had to do a Endian conversion

byte[] ip = BitConverter.GetBytes(ipInt);
Array.Reverse(ip);

IPAddress = new IPAddress(BitConverter.ToUInt32(ip,0))
FlappySocks