F#中的数据类型
F#主要支持 4 种类型的数据类型。
Types | Data Types |
---|---|
Primitive data types | char, byte, bool, int, float |
Derived data types | class, array, list, records, sequence |
Enumeration | enum |
Unit type | it is used if other data types are not specified. |
1)F#基本数据类型
基本数据类型基于整数和浮点类型。 F#支持有符号和无符号字面量。
Data Types | Description | Range | Suffix Or Prefix |
---|---|---|---|
bool | Possible values are true and false | NA | |
sbyte | signed 8-bit integer | -128 to 127 | y |
byte | unsigned 8-bit natural number | 0 to 255 | uy |
int16 | signed 16-bit integer | -32768 to 32767 | s |
uint16 | unsigned 16-bit natural number | 0 to 65535 | us |
int or int32 | signed 32-bit integer | -231+1 to 231-1 | us |
uint or uint32 | unsigned 32-bit natural number | 0 to 4,294,967,295 | u or ui |
nativeint | Native pointer as a signed natural number | n | |
unativeint | native pointer as an unsigned natural number | un | |
int64 | signed 64-bit integer | -263+1 to 0 to 263-1 | un |
uint64 | unsigned 64-bit natural number | 0 to 263-1 | ul |
single or float32 | 32-bit floating point number | F or f | |
float; double | 64-bit floating point number | none | |
bigint | integer not limited to 64-bit representation | l | |
decimal | fractional number represented as a fixed point or rational number | M or m | |
Char | Unicode character | none | |
String | Unicode string | None | |
Byte | Ascii character | B | |
Byte[] | Ascii string | B | |
unit | Indicates 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. | ||
Void | Indicates no type or value. | ||
String or byte[] | Verbatim string | @prefix |
2)F#派生数据类型
F#派生的数据类型是类,数组,结构等。我们将在后面讨论。
3)F#枚举
我们将在下一章中讨论枚举。
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论