本文介绍了MemoryStream不包含GetBuffer()的定义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经开始使用C#和.NET Core,并且正在尝试在

I've started working with C# and .NET Core and I'm trying to implement the code in the answer at https://stackoverflow.com/a/23739932/1459684

不过,我在
writer行中遇到问题。 (innerStream.GetBuffer(),0,length);

var base64 = Convert.ToBase64String(stream.GetBuffer(),0,( int)stream.Length).ToCharArray();
,其中方法 getBuffer()似乎不再可用。我收到错误:

However, I have a problem with lines writer.Write(innerStream.GetBuffer(), 0, length); and var base64 = Convert.ToBase64String(stream.GetBuffer(), 0, (int)stream.Length).ToCharArray(); where the method getBuffer() no longer appears to be available. I receive the error:

使用Google仅此情况的其他实例似乎位于,但没有说明应该进行哪些重构。

With a Google the only other instance of this seems to be at https://github.com/hultqvist/ProtoBuf/issues/35 but does not give me an indication of what refactoring I should make.

推荐答案

而不是 GetBuffer ,您需要使用。

Rather than GetBuffer you need to use TryGetBuffer.

请参见更多详细信息。

这篇关于MemoryStream不包含GetBuffer()的定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-16 07:05