Most voted "using" questions
21 questions
Sort by count of
-
18
votes1
answer314
viewsIs it correct to use a block using inside another using block?
It is correct to use a block using inside another block using as in the example below? or just put the first using? public DataTable Listar(string stringMySql, CommandType commandType,…
-
18
votes3
answers703
viewsCan I remove all the using I’m not using?
I took a project here ASP.NET C# and realize that I can remove several "using". I can get out of these using or not? Did the using which is not used in class can be used by someone who is using the…
-
13
votes1
answer292
viewsWhat is the difference between "using" and "using Static"?
In a question I asked about C#, @Maniero answered me and put an example code in Dotnetfiddle. The code is this: using static System.Console; public class Program { public static void Main() { var…
-
12
votes2
answers348
viewsShould or should not Httpclient be used within a using block?
Reading this reply, a question relating to the use of using, I was curious about the following statement: In fact everyone uses HttpClient wrong, I even used and did not know everything, because I…
-
11
votes2
answers252
viewsDifference between instantiating class and using
I can instantiate a class in two ways in C#, they being: HttpClient http = new HttpClient(); or using (var http = new HttpClient()) { // } Is there any difference between these means? Performance?…
-
10
votes2
answers229
viewsCan try catch be replaced by using?
I always used the blocks try, catch and finally when programming in Java, and when I switched to C# I noticed that some codes exchange the try/catch for using. Example: using (FileStream fs = new…
-
9
votes2
answers477
viewsWhat types of resources are released in a "using" statement?
According to Microsoft documentation: The using statement provides a convenient syntax that ensures use correct of Idisposable objects. Source. That is, the interface Idisposable provides a…
-
6
votes1
answer219
viewsHow does the . NET "using" and Garbage interface work?
In a reply now deleted here on the site it seems that there was some confusion with the content indicating the use of GC.Collect() and how the using C# works. So how does it actually work using and…
-
5
votes1
answer151
viewsHow to avoid repeating "using" in ASP.NET MVC?
I have a controller where several moments have a code similar to this: public ActionResult ListarProduto() { using (DBModels db = new DBModels()) { return View(db.Produto.ToList()); } } How not to…
-
4
votes1
answer87
views -
4
votes1
answer64
viewsCompiler indicates non-existent Enum that exists
I’m using the Mono compiler. When I tried to compile this: using static System.Globalization.CharUnicodeInfo; using static System.Globalization.UnicodeCategory; namespace AS3Kit.Lexical { static…
-
3
votes1
answer66
viewsHttpclient reuse and an Apicontroller lifecycle
Based on that website and also in some answers from Stackoverflow [en] I came to the conclusion that I shouldn’t use the class HttpClient in a block using despite the same implement IDisposable.…
-
2
votes2
answers80
viewsHow to ensure that the instantiation of a class is done only through "using"?
I am creating a DLL with some database features (ADO.Net). It would be very convenient to ensure that instantiation of connections is always used only via using (block), not to forget to call the…
-
2
votes1
answer59
viewsWhat happens when using namespace within a namespace?
What happens when I use the directive using namespace x within a namespace? For example: namespace x { int k = 1; } namespace y { using namespace x; } Now when I use the namespace y can access…
-
2
votes1
answer55
viewsIs there a maximum amount of use of "using"?
My initial doubt was whether it was right to use using inside using, I was able to answer that question: It is correct to use a block using within another block using? But I kept asking myself, is…
-
1
votes0
answers46
viewsWhen to use namespace in C++?
Here’s the thing, since I knew how to use using namespace std; was a bad practice I stopped using namespace. Only now I started studying the Opencv library and see in its documentation to use using…
-
1
votes2
answers110
viewsBlock using and Exceptions
Is there any way to report code errors in the block using as in the try we have the catch? Or using the using I’m stuck with a plethora of if, else if and else? Supposing that the block using force…
-
0
votes1
answer36
viewsProblems using "using" to access static methods
I created in C# a static class with the methods Decode() and Encode() as in the code below: namespace Crypt { public static class CaesarCipher { public static string Decode(string text, byte key) {…
-
-1
votes2
answers88
viewsIs it possible to view all the content of a C++ namespace?
When you make the directive: using namespace std; //primeira forma You get direct access to all elements of the Std namespace. But imagine that you want to use only the std::cout or std::endl so it…
-
-1
votes1
answer105
viewsDispose in Unit Of Work
I have a web application and am using repository* and Unit Of Work. In some examples I saw that after performing some change operation in the bank we should call the method Dispose(). I instancei…
-
-1
votes0
answers19
viewsHow does the "Using" directive find Nuget packages?
Hello, I’m beginner in programming, I’m using. NET and after installing a package by Nuget did not understand how the Using directive finds the package I want, as well as its classes. I don’t know…