Problem with the Collection builder example #41756
Labels
doc-enhancement
Improve the current content [org][type][category]
dotnet-csharp/svc
lang-reference/subsvc
Pri1
High priority, do before Pri2 and Pri3
Type of issue
Code doesn't work
Description
I'm writing the spec for the "collections expressions" feature for the Ecma C# standard, and used your tutorial to get up to speed on this topic. While playing with your Collection builder example I found a shortcoming. Regardless of how many elements are in the collection expression, the result returned is a collection of 80, based on the fixed size of the
char
array allocated. Specifically, for a collection expression with 3 elements, one would expect the type'sCount
orLength
property to be 3, but on enumeration, one gets 80 elements. As such, the type is not well-behaved, so is not the best example in that regard. You writeHere is my test; it fixes this problem; it adds a
Count
property and an indexer, and it's generic.Page URL
https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/operators/collection-expressions
Content source URL
https://github.com/dotnet/docs/blob/main/docs/csharp/language-reference/operators/collection-expressions.md
Document Version Independent Id
49349466-94fd-00b5-93da-e4200d9f9ec8
Article author
@BillWagner
Metadata
The text was updated successfully, but these errors were encountered: