C# - WinRT - 将 IPv4 地址从 uint 转换为字符串?

标签 c# windows-runtime ipv4 uint

我有一个 IPv4 地址作为 uint 提供,我想将其转换为 string(用于记录)。

我通常会在 C# 中使用 System.Net.IPAddress 构造函数来实现这一点...但似乎 System.Net.IPAddress 在 C# 中不可用WinRT/Windows 商店。有没有人有等效的方法来进行这种转换?

谢谢。

最佳答案

有点“脏”,但似乎能用

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

这种情况的输出是 255.223.95.79

关于C# - WinRT - 将 IPv4 地址从 uint 转换为字符串?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22058697/

相关文章:

javascript - Windows 8 (JavaScript) : Multiple <video> tags with same webcam source: Possible?

c# - 在 WinRT 中加载图像文件

java - Tomcat 中的 HttpServletRequest.getRemoteAddr() 返回 IPv6 格式的 IP 地址

c# - Ping 网络上的主机名

c++ - 如何取消C++/WRL中的异步回调函数?

c# - WP8 LongListSelector 中的自动高度图像

oracle - 在 Oracle 中表示 IPv4/IPv6 地址

c++ - 将 getifaddrs 移植到 Win XP

c# - 显示 Prism 模块内部的 Prism 模块

c# - 空条件运算符