如何将int64转换为Nullable< int64>

编程入门 行业动态 更新时间:2024-10-24 16:23:27
本文介绍了如何将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;

本文发布于:2023-11-11 06:55:13,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1577692.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:转换为   如何将   Nullable   lt   amp

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!