This chapter presented the Framework Class Library’s string
- and character-processing capabilities. We overviewed the fundamentals of characters and strings. You saw how to determine the length of strings, copy strings, access the individual characters in strings, search strings, obtain substrings from larger strings, compare strings, concatenate strings, replace characters in strings and convert strings to uppercase or lowercase letters.
We showed how to use class StringBuilder
to build strings dynamically. You learned how to determine and specify the size of a StringBuilder
object, and how to append, insert, remove and replace characters in a StringBuilder
object. We then introduced the character-testing methods of type Char
that enable a program to determine whether a character is a digit, a letter, a lowercase letter, an uppercase letter, a punctuation mark or a symbol other than a punctuation mark, and the methods for converting a character to uppercase or lowercase.
In the online Regex
section, we discussed classes Regex
, Match
and MatchCollection
from namespace System.Text.RegularExpressions
and the symbols that are used to form regular expressions. You learned how to find patterns in a string
and match entire string
s to patterns with Regex
methods Match
and Matches
, how to replace characters in a string
with Regex
method Replace
and how to split string
s at delimiters with Regex
method Split
. In the next chapter, you’ll learn how to read data from and write data to text files. We’ll also demonstrate C#’s object-serialization mechanism that can convert objects into bytes so you can output and input objects.