Professional C# 2005
by Christian Nagel, Bill Evjen, Jay Glynn, Karli Watson, Morgan Skinner, Allen Jones
Chapter 8. Strings and Regular Expressions
In the beginning of this book, you have been almost constantly using strings and have taken for granted the stated mapping that the string keyword in C# actually refers to the .NET base class System.String. System.String is a very powerful and versatile class, but it is by no means the only string-related class in the .NET armory. This chapter starts off by reviewing the features of System.String, and then looks at some quite nifty things you can do with strings using some of the other .NET classes—in particular those in the System.Text and System.Text.RegularExpressions namespaces. This chapter covers the following areas:
Building strings—If you're performing repeated modifications on a string, for example in order to build up a lengthy string prior to displaying it or passing it to some other method or application, the
Stringclass can be very inefficient. For this kind of situation, another class,System.Text.StringBuilderis more suitable, because it has been designed exactly for this situation.Formatting expressions—You also take a closer look at those formatting expressions that have been used in the
Console.WriteLine()method throughout these last few chapters. These formatting expressions are processed using a couple of useful interfaces,IFormatProviderandIFormattable, and by implementing these interfaces on your own classes, you can actually define your own formatting sequences so thatConsole.WriteLine()and similar classes ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access