Home > DeveloperSection > Forums > MemoryStream in Using Statement - Do I need to call close()
Jayden Bell
Jayden Bell

Total Post:105

Points:739
Posted on    February-03-2014 12:04 AM

 C# C# 
Ratings:


 1 Reply(s)
 959  View(s)
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();

    }



Pravesh Singh

Total Post:411

Points:2881
Posted on    February-03-2014 12:57 AM

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

}


Don't want to miss updates? Please click the below button!

Follow MindStick