using-statement
What is the relationship between the using keyword and the IDisposable interface?
开发者_开发百科If I am using the using keyword, do I still have to implement IDisposable?You can\'t have one without the other.[详细]
2023-01-13 03:38 分类:问答Can the C# using statement be written without the curly braces?
I was browsing a coworkers c# code today and found the following: using (MemoryStream data1 = new MemoryStream())[详细]
2023-01-12 04:02 分类:问答Closing SqlConnection and SqlCommand c#
In my DAL I write queries like this: using(SQLConnection conn = \"connection string here\") { SQLCommand cmd = new (\"sql query\", conn);[详细]
2023-01-10 01:18 分类:问答Catching exceptions thrown in the constructor of the target object of a Using block
using(SomeClass x = new SomeClass(\"c:/temp/test.txt\")) { ... } Inside the using block, all is fine with treating exceptions as normal. But what if the constructor of SomeClass can throw an excepti[详细]
2023-01-09 03:32 分类:问答Nested using statements
As Eric Gunnerson shows in this blog post, in C# you can nest using statements as: using (StreamWriter w1 = File.CreateText(\"W1\"))[详细]
2023-01-08 21:18 分类:问答Occasions when the using statement and IDisposable should never be used
I was reading about this scenario where making use of the C# using statement can cause problems. Exceptions thrown within the scope of the using block can be lost if the Dispose function called at the[详细]
2023-01-07 22:13 分类:问答What happens if i return before the end of using statement? Will the dispose be called?
I\'ve the following code using(MemoryStre开发者_JAVA技巧am ms = new MemoryStream()) { //code return 0;[详细]
2023-01-06 23:10 分类:问答What classes should I use C#'s using statement with?
I\'ve read and I believe I understand what C#\'s using statement does (please correct me if I\'m wrong): Initializes an IDisposable object as read only to a limited scope (the using block). I know you[详细]
2023-01-06 19:27 分类:问答How should I replicate the functionality of C#'s 'using' statement in Java?
I\'m converting some C# code to Java and it contains the using statement. How should I replicate this functionality in Java? I was going to use a try, catch, 开发者_JS百科finally block but I thought I[详细]
2023-01-06 06:25 分类:问答import statement mess in python
I want to have a number of files imported in a general python fi开发者_C百科le and then include that file when I need the imported modules in the current module. This of course will lead to errors and[详细]
2023-01-06 00:31 分类:问答