+ 2

Using in C#

What is the difference in using "using" in the library declaration and in the part of the code? for example, using (StreamWriter write = new StreamWriter ("")) { // code }

18th Jan 2019, 6:22 AM
Ɓukasz Klein
Ɓukasz Klein - avatar
2 Answers
+ 3
First using is for declaring namespaces and the second using is for dispose everything that created in the bracket after it finished
18th Jan 2019, 10:46 PM
Mahdi (Soroush) Jafari
Mahdi (Soroush) Jafari - avatar
+ 2
This is the same world but it is used for different things. At the first case it is used as derective for more comfortable work with different namespaces. At second case it is used as operator witch allows you to use more convenient syntax for working with IDisposable objects.
18th Jan 2019, 10:06 AM
Earl_Grey
Earl_Grey - avatar