可以使用 Encoding 类的 GetString 方法将 byte[] 数据转化为字符串。示例代码如下:

byte[] bytes = { 72, 101, 108, 108, 111, 32, 87, 111, 114, 108, 100 }; // 字符串 'Hello World'
string str = Encoding.ASCII.GetString(bytes);
Console.WriteLine(str);

输出:

Hello World
C# Byte[] 数组转换为字符串 - 简单方法

原文地址: https://www.cveoy.top/t/topic/nPFn 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录