F# - 什么是数组<'T>? [英] F# - What is array<'T>?
问题描述
在这个上一个问题中我了解到,在F# 数组<'T>
与 System.Array
不同。
In this previous question I learnt that in F# an array<'T>
is not the same as System.Array
.
VS告诉我,数组<'T>
继承 System.Array
并具有全名 Microsoft.FSharp.Core.array< _>
和一些额外的接口。
VS tells me that array<'T>
inherits System.Array
and has the full name Microsoft.FSharp.Core.array<_>
and some additional Interfaces.
然而 MSDN 表示 array<'T>
是 System.Array
的类型缩写。而且它有符号 arr。[i]
来获取和设置项目。
However MSDN says that array<'T>
is a type abbreviation of System.Array
. And that it has the notation arr.[i]
to get and set items.
所以对于我的教训,是数组<'T>
类型缩写,包括类型扩展名和附加接口?
So for my lesson, is array<'T>
a type abbreviation that includes type extensions and additional Interfaces? Where is the best place to look this up ?
推荐答案
类型 array<'T>
是一个缩写,但不是基础类型 System.Array
,而是用于表示F#中的数组的另一个泛型类型,写为$ code>'T [] 。
The type array<'T>
is an abbreviation, but not for the base type System.Array
but for another generic type that represents arrays in F#, which is written as 'T[]
.
这意味着
-
System.Array
是非通用基类型(不能使用索引,您只能将元素作为对象)
System.Array
is the non-generic base type (where you cannot use indexing and you can only get elements as objects)
'T []
和数组<'T>
完全一样的事情它们是支持索引的通用类型,您可以从中获取'T
值。
'T[]
and array<'T>
mean exactly the same thing. They are the generic type which supports indexing and you get 'T
values from it.
这篇关于F# - 什么是数组<'T>?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!