快速获取MemoryStream内容作为ASCII字符串的方法 [英] Quick way to get the contents of a MemoryStream as an ASCII string

查看:91
本文介绍了快速获取MemoryStream内容作为ASCII字符串的方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在MemoryStream中有一个JSON字符串.我正在使用以下代码将其作为ASCII字符串获取:

I have a JSON string in a MemoryStream. I am using the following code to get it out as an ASCII string:

MemoryStream memstream = new MemoryStream(); 
/* Write a JSON string to memstream here */

byte[] jsonBytes = new byte[memstream.Length];
memstream.Read(jsonBytes, 0, (int)memstream.Length);

string jsonString = Encoding.ASCII.GetString(jsonBytes);

最短/最短的方法是什么?

What is a shorter/shortest way to do this?

推荐答案

您可以使用 查看全文

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