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

前端 未结 5 2026
深忆病人
深忆病人 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条回答
  •  萌比男神i
    2020-12-18 05:59

    The first allows you to use types that are not defined in your code (tells the compiler where to find the code it needs to reference. REF: http://msdn.microsoft.com/en-us/library/sf0df423(v=VS.100).aspx

    The second using makes sure that the memory is released upon the end of the code block, or in the case of an exception. REF: http://msdn.microsoft.com/en-us/library/yh598w02.aspx

    Please see the links above for detailed documentation on each.

提交回复
热议问题