問題:
This question already has an answer here: 這個問題在這裏已有答案:
- How to convert UTF-8 byte[] to string? 如何將UTF-8 byte []轉換爲字符串? 13 answers 13個答案
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