What is the difference between the using statement and directive in C#?

前端 未结 5 2017
深忆病人
深忆病人 2020-12-18 05:11

this is basically a tutorial question to ask since am a beginner I would like to what is a difference between the using statement we use at start of our C# code to include a

5条回答
  •  一整个雨季
    2020-12-18 05:36

    I'm sure someone will spend a great deal of time answering what amounts to a Google search but here are a couple of links to get you started.

    The using Statement (C# Reference) ensures that Dispose is called even if an exception occurs while you are calling methods on the object.

    To allow the use of types in a namespace so that you do not have to qualify the use of a type in that namespace use using Directive (C# Reference).

    You may find that MSDN is a great resource to spend some time browsing.

提交回复
热议问题