What are the uses of “using” in C#?

后端 未结 29 2891
有刺的猬
有刺的猬 2020-11-21 07:31

User kokos answered the wonderful Hidden Features of C# question by mentioning the using keyword. Can you elaborate on that? What are the uses of

29条回答
  •  说谎
    说谎 (楼主)
    2020-11-21 08:03

    The using statement tells .NET to release the object specified in the using block once it is no longer needed. So you should use 'using' block for classes that require cleaning up after them, like System.IO Types.

提交回复
热议问题