如何將字節數組轉換爲字符串[duplicate] - How to convert byte array to string [duplicate]

問題:

This question already has an answer here: 這個問題在這裏已有答案:

I created a byte array with two strings. 我用兩個字符串創建了一個字節數組。 How do I convert a byte array to string? 如何將字節數組轉換爲字符串?

var binWriter = new BinaryWriter(new MemoryStream());
binWriter.Write("value1");
binWriter.Write("value2");
binWriter.Seek(0, SeekOrigin.Begin);

byte[] result = reader.ReadBytes((int)binWriter.BaseStream.Length);

I want to convert result to a string. 我想將result轉換爲字符串。 I could do it using BinaryReader , but I cannot use BinaryReader (it is not supported). 我可以使用BinaryReader ,但我不能使用BinaryReader (它不受支持)。


解決方案:

參考一: https://en.stackoom.com/question/mtso
參考二: https://stackoom.com/question/mtso
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章