Geeks With Blogs
Brian Lachniet
Note that the buffer contains allocated bytes which might be unused. For example, if the string "test" is written into the MemoryStream object, the length of the buffer returned from GetBuffer is 256, not 4, with 252 bytes unused. To obtain only the data in the buffer, use the ToArray method; however, ToArray creates a copy of the data in memory.
Posted on Wednesday, April 13, 2011 8:17 AM C# | Back to top

Comments on this post: MemoryStream.ToArray() VS MemoryStream.GetBuffer()

# re: MemoryStream.ToArray() VS MemoryStream.GetBuffer()
Requesting Gravatar...
Nice! What i'm looking for.
Left by Andre Soares on Sep 11, 2013 10:19 AM

Your comment:
 (will show your gravatar)

Copyright © blachniet | Powered by: