Why doesn't Array class expose its indexer directly?

前端 未结 9 1491
谎友^
谎友^ 2020-12-15 18:10

something to mention for answering:

  1. Don\'t worry about variance, while the item in question is Array rather than

9条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-15 18:44

    C# Specs "12.1.1 The System.Array type" says, "Note that System.Array is not itself an array-type"

    Because it is not an array type.

    And note that "6.1.6 Implicit reference conversions" says, "From a single-dimensional array type S[] to System.Collections.Generic.IList and its base interfaces, provided that there is an implicit identity or reference conversion from S to T"

    C# Specs: http://www.microsoft.com/en-us/download/details.aspx?id=7029

    About why the indexer access is so much of a mystery, check this other SO post: implicit vs explicit interface implementation

    hope it helps.

提交回复
热议问题