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

查看:27
本文介绍了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 时,我得到了 类型 bool 与 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.

推荐答案

in f# it's

in f# it's

use dbTrans = new con.BeginTransaction ()

use cmd = con.CreateCommand()

这些将在您的功能结束时处理

these will dispose when your function ends

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

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