简体   繁体   中英

F# - What is array<'T>?

In this previous question I learnt that in F# an array<'T> is not the same as System.Array .

VS tells me that array<'T> inherits System.Array and has the full name Microsoft.FSharp.Core.array<_> and some additional Interfaces.

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.

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 ?

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[] .

This means that

  • System.Array is the non-generic base type (where you cannot use indexing and you can only get elements as objects)

  • 'T[] and array<'T> mean exactly the same thing. They are the generic type which supports indexing and you get 'T values from it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM