Question

I have a IPv4 address provided as a uint and I would like to convert it to string (for the purpose of logging).

I would normally achieve this in C# using the System.Net.IPAddress constructor...but it seems that System.Net.IPAddress is not available in C# for WinRT/Windows Store. Does anyone have an equivalent way to do this conversion?

Thank you.

Was it helpful?

Solution

A little "dirty", but seems to work

        uint ip = 0xFFDF5F4F;
        var bytes = BitConverter.GetBytes(ip);
        string res = string.Join(".", bytes.Reverse());

Output is 255.223.95.79 for this case

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top