How to convert int64 to Nullable<int64>

人盡茶涼 提交于 2020-01-15 04:35:11

问题


This code:

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

produces this compile time error:

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

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?


回答1:


Use the System.Nullable constructor; for example:

> 
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 = ()


来源:https://stackoverflow.com/questions/17172760/how-to-convert-int64-to-nullableint64

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!