1

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

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:

"'MemoryStream' does not contain a definition for 'GetBuffer' and no extension method 'GetBuffer' accepting a first argument of type 'MemoryStream' could be found (are you missing a using directive or an assembly reference?)"

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.

Richard
  • 106,783
  • 21
  • 203
  • 265
Danny
  • 53
  • 1
  • 7
  • @mjwills Yes it did thank you. I should've read more carefully, I saw that `TryGetBuffer` returns a boolean and so assumed it was not what I needed. – Danny Jul 25 '17 at 08:15

1 Answers1

3

Rather than GetBuffer you need to use TryGetBuffer.

See https://github.com/dotnet/corefx/issues/1897 for more details.

mjwills
  • 23,389
  • 6
  • 40
  • 63