Questions tagged as 'using'

3
answers

Can I remove all the use I'm not using?

I took a project here ASP.NET C # and I realize I can pull several "using". Can I exit by removing these using or not? Does using that is not used in class can be used by someone who is using class ? No, right?...
asked by 12.01.2017 / 14:10
1
answer

Is it correct to use a using block inside another using block?

Is it correct to use a block using within another block using as in the example below? or is it enough to just put the first using ? public DataTable Listar(string stringMySql, CommandType commandType, List<MySqlPara...
asked by 02.12.2015 / 15:07
1
answer

What is the difference between "using" and "using static"?

In a question I asked about C #, @bigown answered me and put a sample code in DotNetFiddle. The code is this: using static System.Console; public class Program { public static void Main() { var objects = new [] { ne...
asked by 16.06.2016 / 18:42
2
answers

Try catch can be replaced with using?

I've always used the blocks try , catch and finally when programming in Java, and when I switched to C # I noticed that some codes change try/catch by using . Example: using (FileStream fs = new FileStream("...
asked by 07.08.2016 / 03:19
1
answer

Compiler 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 class Validator { static bool T...
asked by 12.12.2017 / 00:17
1
answer

Nested dispose is required?

I have the following hypothetical code. using (var QDR = new DAL.teste()) { //codigos using (var QDR1 = new DAL.teste1()) { //codigos using (var QDR2 = new DAL.teste2()) { // códigos } } } Is...
asked by 27.06.2016 / 15:39
2
answers

How to ensure that the instantiation of a class is done only through the "using"?

I am creating a DLL with some database functionality (ADO.Net). It would be very convenient to ensure that the instantiation of connections is always only via using (block), so do not forget to call Dispose() / Close() . But...
asked by 12.03.2015 / 21:22
1
answer

Is there a maximum use quantity of "using"?

My initial doubt was, if it was right to use using within using , I managed to cure it in this response: Is it correct to use a using block within another using block? But I was wondering, is there a maximum quantity? Tha...
asked by 28.03.2018 / 21:55
1
answer

Reapping the HttpClient and life cycle of an ApiController

Based on on this site and also on I came to the conclusion that I should not use the class HttpClient in a using block even though it implements IDisposable . This would help reuse the already instantiated object and bring...
asked by 17.12.2018 / 16:49
2
answers

Using block and Exceptions

Is there any way to report errors in codes in block using as in try do we have catch ? Or using using I'm stuck with an infinity of if , else if and else ? Assuming the using block forces y...
asked by 22.05.2018 / 03:03