我正在尝试使用System.Data.SqliteF#.在C#中,我有类似的代码
using (DbTransaction dbTrans = con.BeginTransaction()) {
using (SQLiteCommand cmd = con.CreateCommand()) {
//blahblah
}
dbTrans.Commit();
}
Run Code Online (Sandbox Code Playgroud)
但是在F#中,当我使用using上面类似的两个时,我得到错误the type bool is not compatible with the type IDisposable...
编辑我很抱歉我的问题.use适用于F#案例.我只是不知道如何关闭/删除我的quesetions.
假设以下代码:
let fn () =
use a = new System.IO.StreamWriter ("d:\\test.txt")
a
let b = fn ()
b.Write "t"
Run Code Online (Sandbox Code Playgroud)
它给出以下错误:
ObjectDisposedException:无法写入已关闭的TextWriter.
这是为什么?