none
MemoryStream.Close() RRS feed

  • Question

  • Why can I use the method of 'GetBuffer()' after I have closed memoryStream. Code like this:

    static void Main(string[] args)
            {
                MemoryStream stream = new MemoryStream();
                Byte[] data = new Byte[] { 1, 2, 3, 5 };
                try
                {
                    for (Int32 i = 0; i < 4; i++)
                    {
                        stream.Write(data, 0, 1);
                    }
                    stream.Close();
                    Byte[] result = stream.GetBuffer();
                    Console.WriteLine(result[0]);
                    Console.ReadKey();
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.Message);
                }
            }

    The version of .NET Framework is 2.0.0.0

    Friday, April 10, 2015 8:57 AM

Answers

All replies