Slacker News Slacker News logo featuring a lazy sloth with a folded newspaper hat
  • top
  • new
  • show
  • ask
  • jobs
Library

Comment by pjmlp

3 years ago

Modern C# version,

    using var sr = new StreamReader(filename);

    txt = sr.ReadToEnd();

And for the "what about forgeting to call using?",

https://devblogs.microsoft.com/dotnet/infer-interprocedural-...

No different from using all those static analisers in C and C++ to keep the code free of memory corruptions and UB issues.

1 comment

pjmlp

Reply

MaxBarraclough  3 years ago

Does it behave identically without the braces?

Slacker News

Product

  • API Reference
  • Hacker News RSS
  • Source on GitHub

Community

  • Support Ukraine
  • Equal Justice Initiative
  • GiveWell Charities