f#关键字的使用和使用 [英] f# keyword use and using

查看:116
本文介绍了f#关键字的使用和使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将System.Data.Sqlite与F#一起使用.在C#中,我有类似

I am trying to use System.Data.Sqlite with F#. In C#, I have code like

 using (DbTransaction dbTrans = con.BeginTransaction()) {
     using (SQLiteCommand cmd = con.CreateCommand()) {
         //blahblah
     }
     dbTrans.Commit();
 }

但是在F#中,当我使用上面类似的两个using时,出现了the type bool is not compatible with the type IDisposable的错误... 编辑,我真的很抱歉. use将在F#情况下工作.我只是不知道如何关闭/删除我的照护者.

But in F#, when I use the similiar two using above I got error of the type bool is not compatible with the type IDisposable... EDIT I am really sorry for my question. use would work in F# case. I just dont know how to close/delete my quesetions.

推荐答案

在f#中是

use dbTrans = new con.BeginTransaction ()

use cmd = con.CreateCommand()

这些将在您的函数结束时处理

these will dispose when your function ends

这篇关于f#关键字的使用和使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆