如何将byte []转换为字符串 [英] How do I convert byte[] to string

查看:119
本文介绍了如何将byte []转换为字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

UnicodeEncoding utf16 = new UnicodeEncoding();



string saltValueString = utf16.GetString(saltValue); //字符串到字节[]



我如何为byte []做字符串?

解决方案

  byte  [] b =  new   byte  [ 1024 ]; 
string test = System.Text.Encoding.ASCII.GetString(b);


< blockquote>使用System.Text.Encoding。& ltUnicodeEncoding > .GetString(你的字节数组)

注意UnicodeEncoding应该是你的字节数组编码类型



例如

  string  stringvalue = System.Text.Encoding .UTF8.GetString(byteArr); 


UnicodeEncoding utf16 = new UnicodeEncoding();

string saltValueString = utf16.GetString(saltValue); // string to byte[]

How do I do for byte[] to string?

解决方案

byte[] b = new byte[1024];
string test = System.Text.Encoding.ASCII.GetString(b);


use System.Text.Encoding.&ltUnicodeEncoding>.GetString( your byte array)
note UnicodeEncoding should your byte array encoding type

for example

string stringvalue = System.Text.Encoding.UTF8.GetString(byteArr);


这篇关于如何将byte []转换为字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆