.net – Reset or Clear .NET MemoryStream

.netmemorystream

The .NET MemoryStream does not appear to have a .Reset or .Clear method.

I was thinking of using the following code to accomplish this:

ms.Seek(0, IO.SeekOrigin.Begin)
ms.SetLength(0)

What is the proper way to clear or reset an existing .NET MemoryStream?

Best Solution

Why do you need resetting memory stream? You always can create a new one. Or you can use:

memoryStream.SetLength(0);