F#中的数据类型

发布于 2024-10-05 13:14:24 字数 3080 浏览 4 评论 0

F#主要支持 4 种类型的数据类型。

TypesData Types
Primitive data typeschar, byte, bool, int, float
Derived data typesclass, array, list, records, sequence
Enumerationenum
Unit typeit is used if other data types are not specified.

1)F#基本数据类型

基本数据类型基于整数和浮点类型。 F#支持有符号和无符号字面量。

Data TypesDescriptionRangeSuffix Or Prefix
boolPossible values are true and falseNA 
sbytesigned 8-bit integer-128 to 127y
byteunsigned 8-bit natural number0 to 255uy
int16signed 16-bit integer-32768 to 32767s
uint16unsigned 16-bit natural number0 to 65535us
int or int32signed 32-bit integer-231+1 to 231-1us
uint or uint32unsigned 32-bit natural number0 to 4,294,967,295u or ui
nativeintNative pointer as a signed natural number n
unativeintnative pointer as an unsigned natural number un
int64signed 64-bit integer-263+1 to 0 to 263-1un
uint64unsigned 64-bit natural number0 to 263-1ul
single or float3232-bit floating point number F or f
float; double64-bit floating point number none
bigintinteger not limited to 64-bit representation l
decimalfractional number represented as a fixed point or rational number M or m
CharUnicode character none
StringUnicode string None
ByteAscii character B
Byte[]Ascii string B
unitIndicates the absence of an actual value. The type has only one formal value which is denoted (). The unit value, (), is often used as a placeholder where a value is needed but no real value is available.  
VoidIndicates no type or value.  
String or byte[]Verbatim string @prefix

2)F#派生数据类型

F#派生的数据类型是类,数组,结构等。我们将在后面讨论。

3)F#枚举

我们将在下一章中讨论枚举。

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据

关于作者

飘过的浮云

暂无简介

0 文章
0 评论
535 人气
更多

推荐作者

忆伤

文章 0 评论 0

眼泪也成诗

文章 0 评论 0

zangqw

文章 0 评论 0

旧伤慢歌

文章 0 评论 0

qq_GlP2oV

文章 0 评论 0

旧时模样

文章 0 评论 0

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文