Examples from Chapter 5 (Collections) of Programming C# 10.0 (O'Reilly).
- Example 1. Creating arrays
- Example 2. Accessing array elements
- Example 3. Convoluted array access
- Example 4. How not to modify an array with immutable elements
- Example 5. Modifying an array with immutable elements
- Example 6. Laborious array initialization
- Example 7. Array initializer syntax
- Example 8. Shorter array initializer syntax
- Example 9. Array initializer syntax with element type inference
- Example 10. Array as argument
- Example 11. Searching with IndexOf
- Example 12. Searching with FindIndex
- Example 13. Using a lambda with FindIndex
- Example 14. Finding multiple items with FindAll
- Example 15. Sorting an array, and BinarySearch
- Example 16. Creating a jagged array
- Example 17. Rectangular arrays
- Example 18. A 2×3×5 cuboid “rectangular” array
- Example 19. Using a List<T>
- Example 20. List initializer
- Example 21. List initializer with target-typed
new
- Example 22. IEnumerable<T> and IEnumerable
- Example 23. IEnumerator<T> and IEnumerator
- Example 24. IAsyncEnumerable<T> and IAsyncEnumerator<T>
- Example 25. ICollection<T>
- Example 26. IList<T>
- Example 27. Trying (and failing) to enlarge an array
- Example 28. A simple iterator
- Example 29. A very simple iterator
- Example 30. An infinite iterator
- Example 31. Implementing IEnumerable<T> by hand
- Example 32. Iterator argument validation
- Example 33. Accessing the last element of an array with an end-relative index
- Example 34. Getting a subrange of an array with the range operator
- Example 35. Some start-relative and end-relative Index values
- Example 36. End-relative indexing, and pre-Index equivalents
- Example 37. Various ranges
- Example 38. Getting a substring with a range
- Example 39. Getting a subrange of an ArraySegment<T> with the range operator
- Example 40. Getting a subrange of a span with the range operator
- Example 41. Minimally enabling Index
- Example 42. Minimally enabling Range
- Example 43. How range indexing expands