如何将int64转换为Nullable< int64> [英] How to convert int64 to Nullable<int64>

查看:61
本文介绍了如何将int64转换为Nullable< int64>的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

此代码:

let mutable x : Nullable<int64> = new  Nullable<int64> 99L
let y : int64 = 88L
x <- y

产生此编译时错误:

该表达式应具有Nullable类型,但此处具有int64类型

This expression was expected to have type Nullable but here has type int64

我了解错误,我想知道的是将 y (88)中的值分配给 x 的正确方法(广播?)是什么?

I understand the error, what I would like to know is what is the correct way (cast?) to assign the value in y (88) to x?

推荐答案

使用 System.Nullable 构造函数;例如:

> 
let mutable x = System.Nullable (99L)
let y = 88L
x <- System.Nullable y;;

val mutable x : Nullable<int64> = 88L
val y : int64 = 88L
val it : unit = ()

这篇关于如何将int64转换为Nullable&lt; int64&gt;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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