C# 如何将argotic.feed.save结果写入内存流?

C# 如何将argotic.feed.save结果写入内存流?,c#,stream,argotic,C#,Stream,Argotic,我想写入memorystream,然后将其作为字符串返回给另一个函数。 这就是我写的: Stream st = new MemoryStream(); Feed.Save(st); //argotic Save method has the ability to write into Stream StreamReader sr = new StreamReader(st); return sr.Re

我想写入memorystream,然后将其作为字符串返回给另一个函数。 这就是我写的:

            Stream st = new MemoryStream();
            Feed.Save(st); //argotic Save method has the ability to write into Stream
            StreamReader sr = new StreamReader(st);
            return sr.ReadToEnd();
但是我只得到了一个空字符串,尽管st.length显示了正确的长度,但其中没有字符:-

我怎样才能解决这个问题


关于。

保存后,将流的位置重置为0,以便从头开始读取。否则,您将从当前位置读取,该位置是流的结尾,因为它刚刚被写入:

st.Position = 0;

使用流时,您应该熟悉使用语句的
。我完全熟悉如何使用“using”上面的代码片段是为了给出一个示例。感谢您的回答,我已经将代码更改为:int I=st.Read(b,0,(int)st.Length);然后将字节转换为字符串,现在它可以工作了:)