相关疑难解决方法(0)

f#关键字使用和使用

我正在尝试使用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.

f#

15
推荐指数
2
解决办法
3154
查看次数

使用F#的'use'关键字范围

假设以下代码:

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.

这是为什么?

f# scope

1
推荐指数
2
解决办法
387
查看次数

标签 统计

f# ×2

scope ×1