Dear Developers,
Please help.
Are all objects declared in a using block disposed and released when the using block closes?
I think that is the case and, as such, I think the Version1 and Version2 of the code samples below are (pretty much) the same, and there is no real need for the nested using here.
What do you know about this?
Please advise.
Thanks.
-- Mark Kamoski
 
 
//Version1... using (WebResponse myResponseTemp = myRequest.GetResponse()) { using (FileStream myStreamTemp = new FileStream(myFilePathComplete, FileMode.Create, FileAccess.Write)) { myResponseTemp.GetResponseStream().CopyTo(myStreamTemp); } } //Version2... using (WebResponse myResponseTemp = myRequest.GetResponse()) { FileStream myStreamTemp = new FileStream(myFilePathComplete, FileMode.Create, FileAccess.Write); myResponseTemp.GetResponseStream().CopyTo(myStream ...

Go to the complete details ...