When are C# “using” statements most useful?

后端 未结 14 1915
没有蜡笔的小新
没有蜡笔的小新 2021-02-13 05:33

So a using statement automatically calls the dispose method on the object that is being \"used\", when the using block is exited, right?

But when is this necessary/benef

14条回答
  •  野趣味
    野趣味 (楼主)
    2021-02-13 06:04

    the "Using" comes into play when a resource needs to be disposed and it implements the IDisposable interface.

提交回复
热议问题