Strings and text Flashcards
1
Q
Strings and text
A
In C#, all strings are immutable.
2
Q
Inefficient built-in string APIs
A
String.StartsWith, default culture 137 String.EndsWith, default culture 542 String.StartsWith, ordinal 115 String.EndsWith, ordinal 34 Custom StartsWith replacement 4.5 Custom EndsWith replacement 4.5
3
Q
Regular Expressions
A
While Regular Expressions are a powerful way to match and manipulate strings, they can be extremely performance-intensive. Further, due to the C# library’s implementation of Regular Expressions, even simple boolean IsMatch queries allocate large transient datastructures “under the hood.” This transient managed memory churn should be deemed unacceptable, except during initialization.
4
Q
XML, JSON and other long-form text parsing
A
Option 1: Parse at build time
Option 2: Split and lazy load
Option 3: Threads