For a call to a WinApi function I needed to convert an IP Address to an Integer in C#.

This can be done using the System.Net.IPAddress class:

Although this works, the compiler issues a warning: 

warning CS0618: ‘System.Net.IPAddress.Address’ is obsolete: ‘This property has been deprecated. It is address family dependent. Please use IPAddress.Equals method to perform comparisons.′

This warning is issued because the Address property is not IPv6 compatible. The warning can be suppressed like this:

But it would be better to use the non deprecated GetAddressBytes() Method: