About 753,000 results
Open links in new tab
  1. What are the uses of "using" in C#? - Stack Overflow

    Mar 8, 2017 · 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 using?

  2. What is the C# Using block and why should I use it? [duplicate]

    The using statement is used to work with an object in C# that implements the IDisposable interface. The IDisposable interface has one public method called Dispose that is used to …

  3. c# - returning in the middle of a using block - Stack Overflow

    The using statement ensures that Dispose is called even if an exception occurs while you are calling methods on the object. You can achieve the same result by putting the object inside a …

  4. c# - Why use a using statement with a SqlTransaction? - Stack …

    The using statement is closing and disposing your connection and transaction for you. It's the equivalent of having a finally block on your try/catch that does the dispose.

  5. c# - How to use the `using` statement in method - Stack Overflow

    Apr 17, 2018 · You seem to be misunderstanding what the using statement does in this case. You cannot do it inside of a method, it needs to be outside of a class. The using statement in this …

  6. exception - C# "Using" Syntax - Stack Overflow

    May 4, 2011 · Since the StreamReader class implements IDisposable, the using statement will take care of the disposal of the object. Because the using statement acts like a finally block, it …

  7. How do I use the C#6 "Using static" feature? - Stack Overflow

    Aug 6, 2015 · The static Keyword on a using statement will import only the one, specified type (and its nested types). Furthermore you must not give the type name anymore. So just add …

  8. Should 'using' directives be inside or outside the namespace in C#?

    2440 I have been running StyleCop over some C# code, and it keeps reporting that my using directives should be inside the namespace. Is there a technical reason for putting the using …

  9. c# - Should try/catch be inside or outside a using block ... - Stack ...

    Jan 26, 2016 · Look at using Statement (C# Reference) The using statement ensures that Dispose is called even if an exception occurs while you are calling methods on the object. You …

  10. c# - When should I use the using Statement? - Stack Overflow

    1 Use using for all objects which you instantiate that implement IDisposable unless their lifetime extends beyond the current scope of execution (I.e. method call). In that case, for instance if …