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();
}
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
No, it’s not.
usingensures thatDispose()will be called, which in turn calls theClose()method.You can assume that all kinds of Streams are getting closed by the
usingstatement.From MSDN: