F#-什么是array' T& gt ;? [英] F# - What is array<'T>?
问题描述
在这个上一个问题中,我在F#中了解到 array<'T>
与 System.Array
不同。
In this previous question I learnt that in F# an array<'T>
is not the same as System.Array
.
VS告诉我 array<'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.
因此,在我的课程中, array<'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#中数组的泛型类型的缩写,写为'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 []
和 array<'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#-什么是array&#39; T& gt ;?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!