The .NET Framework provides two basic classes for manipulating text: the String and String-Builder classes. The String class exposes a large number of practical methods, and they’re all reference methods: They don’t act on the string directly but … [Read more...] about Handling Strings and Characters
Handling Strings, Characters and Dates
The Char Class
The Char data type stores characters as individual, double-byte (16-bit), Unicode values; and it exposes methods for classifying the character stored in a Char variable. You can use methods such as IsDigit and IsPunctuation on a Char variable to … [Read more...] about The Char Class
The String Class
The String class implements the String data type, which is one of the richest data types in terms of the members it exposes. We have used strings extensively in earlier chapters, but this is a formal discussion of the String data type and all of the … [Read more...] about The String Class
The StringBuilder Class
The StringBuilder class stores dynamic strings and exposes methods to manipulate them much faster than the String class. As you will see, the StringBuilder class is extremely fast, but it uses considerably more memory than the string it holds. To use … [Read more...] about The StringBuilder Class
The StringReversal Project – StringBuilder
To get an idea of how efficiently the StringBuilder manipulates strings, Figure 9.1 shows an application that reverses a string. The program reverses two strings — one declared as String, and another one declared as StringBuilder. Note that neither … [Read more...] about The StringReversal Project – StringBuilder
The CountWords Project – StringBuilder
The StringBuilder class doesn’t provide as many methods as the String class. It’s used primarily to build long strings and manipulate them dynamically. If you want to locate words or other patterns in the text, align strings in fixed-length fields, … [Read more...] about The CountWords Project – StringBuilder
The DateTime Class
Another common task in coding business applications is the manipulation of dates and times. To aid the coding of these tasks, the Framework provides the DateTime and TimeSpan classes. The DateTime class handles date and time values, whereas the … [Read more...] about The DateTime Class
The TimeSpan Class
The last class discussed in this chapter is the TimeSpan class, which represents a time interval and can be expressed in many different units — from ticks and milliseconds to days. The TimeSpan is usually the difference between two date/time values, … [Read more...] about The TimeSpan Class