Top "Using" questions

"using" is a keyword in some programming languages (C++, C#, VB.

yield return statement inside a using() { } block Disposes before executing

I've written my own custom data layer to persist to a specific file and I've abstracted it with a custom …

c# .net-2.0 idisposable using yield-return
C# 8 understanding await using syntax

I have next method: public async Task<IEnumerable<Quote>> GetQuotesAsync() { using var connection = new SqlConnection(_connectionString); …

c# async-await resharper using c#-8.0
Struct and IDisposable

I wonder why does it not compile? public static void Main(string[] args) { using (MyStruct sss = new MyStruct()) { sss.s = "…

c# .net idisposable using
Calling Dispose() vs when an object goes out scope/method finishes

I have a method, which has a try/catch/finaly block inside. Within the try block, I declare SqlDataReader as …

c# idisposable using using-statement
Why do type aliases in C++ use 'using' instead of 'typedef' in their syntax?

Clearly, type aliases and templated type aliases are semantically equivalent to typedefs and an extension of typedefs to support template. …

c++ templates c++11 typedef using
Try/Finally block vs calling dispose?

Is there any difference between these two code samples and if not, why does using exist? StreamWriter writer; try { writer = …

c# try-catch dispose using streamwriter
Combining foreach and using

I'm iterating over a ManageObjectCollection.( which is part of WMI interface). However the important thing is, the following line of …

c# foreach idisposable using
Using statement and try-catch()-finally repetition?

The using(...) statement is syntactic sugar for try{} finally {}. But if I then have a using statement like below: using (…

c# using try-catch-finally
How to select a single overload of a function with using namespace::function in C++?

consider the following C++ code. namespace A { void f() { // first function } void f(int) { // second function } } ... using A::f; // introduces …

c++ namespaces using
Do you need to call Flush() on a stream or writer if you are using the “using” statement?

I am not sure whether I need to call Flush() on the used objects if I write something like this: …

c# stream using flush writer