MemoryStream in Using Statement - Do I need to call close()

Total Post:110

Points:774

C# 
C#
 1598  View(s)
Ratings:
Rate this:

When using a memory stream in a using statement do I need to call close? For instance is ms.Close() needed here?

  using (MemoryStream ms = new MemoryStream(byteArray)) 
    { 
      // stuff
      ms.Close();
    }
  1. Re: MemoryStream in Using Statement - Do I need to call close()

    Hi jayden,

    No, you don't need. It will be called by the .Dispose() method which is automatically called:

    using (MemoryStream ms = new MemoryStream(byteArray))

        // stuff
    }

      Modified On Apr-04-2018 03:55:54 AM

Answer

Please check, If you want to make this post sponsored

You are not a Sponsored Member. Click Here to Subscribe the Membership.