English
Summary
Conclusions
An array stores a fixed number of elements of one type, accessed by zero-based indices; indices from the end ^n and ranges a[x..y] simplify working with the end and portions of an array. An array is a reference type, so assignment copies the reference; use Clone or Array.Copy to create an independent copy. The Array class provides methods for sorting, searching, filling, and resizing. Store tabular data in rectangular arrays T[,] and rows of different lengths in jagged arrays T[][]. A string is an immutable sequence of char characters: its methods return new strings, comparisons use the selected StringComparison, and StringBuilder is used to build large strings in loops. For Ukrainian text, consider culture when sorting and normalize apostrophes.
Self-check questions
- What is an array? How do you create one using a collection expression and the
newoperator? - What values do array elements have after
new double[10]? - What do
a[^1],a[1..^1], anda[..3]mean? - Why does
b = anot copy the array? How do you create a copy? - How does
==compare arrays? - Which
Arrayclass methods do you know? What is required to useBinarySearch? - How does
Array.Resizework? Does it change the length of the existing array? - How does a rectangular array differ from a jagged array? How do you find their dimensions?
- What does string immutability mean? What are its consequences?
- How do
Ordinal,OrdinalIgnoreCase, andCurrentCulturecomparisons differ? - How do you split a string into parts and discard empty parts?
- How do regular, verbatim, interpolated, and raw string literals differ?
- What is the
StringBuilderclass for? When should you use it? - Why does sorting Ukrainian words by character codes produce the wrong order?
- What are regular expressions used for?
Useful links
- Arrays: https://learn.microsoft.com/dotnet/csharp/language-reference/builtin-types/arrays
- Collection expressions: https://learn.microsoft.com/dotnet/csharp/language-reference/operators/collection-expressions
- The
Arrayclass: https://learn.microsoft.com/dotnet/api/system.array - Strings: https://learn.microsoft.com/dotnet/csharp/programming-guide/strings/
- Raw string literals: https://learn.microsoft.com/dotnet/csharp/language-reference/tokens/raw-string
- String comparisons: https://learn.microsoft.com/dotnet/standard/base-types/best-practices-strings
- The
StringBuilderclass: https://learn.microsoft.com/dotnet/standard/base-types/stringbuilder - Regular expression language: https://learn.microsoft.com/dotnet/standard/base-types/regular-expression-language-quick-reference