Examples from Chapter 5 (Collections) of Programming C# 12.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. Initializing an array with a collection expression
- Example 8. Using a spread element to copy an array as part of a collection expression
- Example 9. Array initializer syntax
- Example 10. Shorter array initializer syntax
- Example 11. Array initializer syntax with element type inference
- Example 12. Array as argument
- Example 13. Searching with IndexOf
- Example 14. Searching with FindIndex
- Example 15. Using a lambda with FindIndex
- Example 16. Finding multiple items with FindAll
- Example 17. Sorting an array, and BinarySearch
- Example 18. Creating a jagged array with collection expressions
- Example 19. Creating a jagged array with array initializers
- Example 20. Rectangular arrays
- Example 21. A 2×3×5 cuboid “rectangular” array
- Example 22. Using a List<T>
- Example 23. Initializing a list with a collection expression
- Example 24. List initializer
- Example 25. List initializer with target-typed
new
- Example 26. IEnumerable<T> and IEnumerable
- Example 27. IEnumerator<T> and IEnumerator
- Example 28. IAsyncEnumerable<T> and IAsyncEnumerator<T>
- Example 29. ICollection<T>
- Example 30. IList<T>
- Example 31. Trying (and failing) to enlarge an array
- Example 32. A simple iterator
- Example 33. A very simple iterator
- Example 34. An infinite iterator
- Example 35. Implementing IEnumerable<T> by hand
- Example 36. Iterator argument validation
- Example 37. Accessing the last element of an array with an end-relative index
- Example 38. Getting a subrange of an array with the range operator
- Example 39. Some start-relative and end-relative Index values
- Example 40. End-relative indexing, and pre-Index equivalents
- Example 41. Various ranges
- Example 42. Getting a substring with a range
- Example 43. Getting a subrange of an ArraySegment<T> with the range operator
- Example 44. Getting a subrange of a span with the range operator
- Example 45. Minimally enabling Index
- Example 46. Minimally enabling Range
- Example 47. How range indexing expands
- Example 48. Using a dictionary as part of a cache
- Example 49. Dictionary lookup with indexer
- Example 50. Collection initializer syntax with a dictionary
- Example 51. Object initializer syntax with a dictionary
- Example 52. A case-insensitive dictionary