Closing StreamReader after ReadToEnd
Is it possible somehow to close StreamReader after calling ReadToEnd method in construction like this:
string s = new StreamReader("filename", Encoding.UTF8).ReadToEnd();
Any alternative elegant construction with the same semantics will be also accepted.
I think the method you're really after is File.ReadAllText, if you're just trying to read all the text from a file in the shortest possible code.
If you don't specify the encoding, it will use UTF-8 automatically.