Python
Java
PHP
IOS
Android
Nodejs
JavaScript
Html5
Windows
Ubuntu
Linux
何时处置?
我对所有有关 IDispose 和 使用 语句的讨论感到困惑 我想知道是否有人可以告诉我在下面的测试示例中是否需要使用 using 语句或 IDispose 的某种实现 public class Main MyFile myFile new
c
NET
idisposable
usingstatement
Java有using语句吗?
Java有没有可以在hibernate中打开会话时使用的using语句 在 C 中 它类似于 using var session new Session 因此该对象超出范围并自动关闭 Java 7 推出自动资源块管理 http www in
Java
Hibernate
usingstatement
当从“using”块中调用“return”时会发生什么? [复制]
这个问题在这里已经有答案了 如果我有一个带有这样的 using 块的方法 public IEnumerable
c
idisposable
usingstatement
返回用于在 using C# 中使用的变量
我返回在 using 语句内的 using 语句中创建的变量 听起来很有趣 public DataTable foo using DataTable properties new DataTable do something return
c
Dispose
idisposable
Using
usingstatement
与 .Net 邮件附件一起使用时处置 MemoryStream
我正在使用 MemoryStream 从存储在数据库中的二进制文件添加附件 我的问题是我想正确处置 MemoryStream 使用 using 语句可以轻松完成此操作 但是当我有多个附件时 我不知道如何正确处理多个 MemoryStream
c
NET
idisposable
memoryStream
usingstatement
EF(实体框架)“using”语句的用法
我有一个关于 MVC 的项目 我们选择 EF 进行数据库事务 我们为 BLL 层创建了一些管理器 我找到了很多例子 其中 using使用 语句 即 public Item GetItem long itemId using var db n
c
EntityFramework
garbagecollection
dbcontext
usingstatement
为什么当我“使用”BinaryReader 对象时我的 FileStream 对象被释放?
考虑以下函数 private int GetSomethingFromFile FileStream fs using BinaryReader br new BinaryReader fs fs Seek 0 SeekOrigin Beg
NET
usingstatement
objectdisposedexception
多重使用块c#
我正在开发需要访问数据库的应用程序 使用 using 语句很好 因为 using statement is to ensure that the object is always disposed correctly and it does
c
aspnet
NET
Using
usingstatement
SqlCommand-SqlConnection使用处置问题
根据 MSDN 如果 IDisposable 资源 嵌套的内部using语句包含外部using的资源 语句中 嵌套资源的 Dispose 方法释放 包含的资源 MSDN http msdn microsoft com en us libra
c
Dispose
usingstatement
using 语句和await 关键字在c# 中表现得很好吗
我有一种情况 我正在做一个async调用一个返回和的方法IDisposable实例 例如 HttpResponseMessage response await httpClient GetAsync new Uri http www goo
c
Asynchronous
usingstatement
C# using 语句
我真的很想把这件事从我的脑海里赶出去 请看下面的代码 using DataTable resultTable DBUtility GetSingleDBTableResult connectionString SELECT FROM MyD
c
Using
usingstatement
返回一个 Disposable 对象以在 using 块中使用
如何在函数中返回一次性对象以确保它在函数内正常工作using堵塞 在我的函数中 我想对一次性对象进行操作并解释错误 这使事情变得复杂 到目前为止 我有类似于以下代码的内容 DBHandle GetDB I can t do this bec
c
idisposable
usingstatement
C# using 语句可以不加花括号吗?
今天浏览同事的c 代码 发现了以下内容 using MemoryStream data1 new MemoryStream using MemoryStream data2 new MemoryStream Lots of code 我一直
c
usingstatement
在 using 语句中声明 2 个类型会出现编译错误吗?
我想使用这行代码 using ADataContext dc new ADataContext ConnectionString BDataContext dc2 new BrDataContext ConnectionString 这会产
c
usingstatement
C# using 语句捕获错误
我只是查看 using 语句 我一直知道它的作用 但直到现在还没有尝试使用它 我想出了以下代码 using SqlCommand cmd new SqlCommand reportDataSource new SqlConnection S
c
Using
usingstatement
如何在 using 语句中使用对象初始值设定项?
有没有什么方法可以重构此代码 以便不必使用临时变量 而仍然使用与对象初始值设定项关联的语法糖 FrmSomeForm someTempForm new FrmSomeForm SomePropA A SomePropB B SomeProp
c
refactoring
Using
usingstatement
捕获Using块的目标对象的构造函数中抛出的异常
using SomeClass x new SomeClass c temp test txt 在 using 块内 一切正常 可以正常处理异常 但是如果构造函数SomeClass可以抛出异常吗 将您的使用放入 try catch fe 中
c
Exception
usingstatement
using 块中实例化的所有一次性对象是否都已处理?
这是我过去多次问自己的问题 因为我使用 5 层深度的语句进行嵌套 正在阅读docs http msdn microsoft com en us library yh598w02 aspx并没有发现任何提及other在块内实例化的一次性物品我
c
VBNET
Dispose
usingstatement
处理 .NET IDisposable 对象
我用 C 工作 而且我对使用相当松懈using块来声明实现的对象IDisposable 显然你总是应该这样做 然而 我没有找到一种简单的方法来知道我何时犯了错误 Visual Studio 似乎没有以任何方式表明这一点 我只是错过了什么吗
c
NET
VisualStudio
idisposable
usingstatement
C#.NET 使用块
我想在我的 DAL 层中使用 using 块 喜欢 using SqlConnection con new SqlConnection connection string Command object Reader object 由于 Sq
c
usingstatement
1
2
3
»