I have a method that returns like this:
using (var response = request.GetResponse())
using (var stream = response.GetResponseStream())
using (var reader = new StreamReader(stream))
return reader.ReadToEnd();
Can I combine the three usings like this and have the same level of safety?
using (var reader = new StreamReader(request.GetResponse().GetResponseStream()))
return reader.ReadToEnd();
Or since this is inside a privately scoped function, can I return safely without a using?
return new StreamReader(request.GetResponse().GetResponseStream()).ReadToEnd();
The object that contains this method is not IDisposable
. I'm guessing no to both my questions but I am curious on other viewpoints.