- Preparing Your Machine to Work with Strings
- Working with Strings
- Initializing Strings
- Comparing Strings
- Concatenating Strings
- Finding the String Length
- Comparing and Concatenating Strings in the Sample Application
- Creating Strings from Characters
- Using Escape Characters
- Using Literal Strings
- Accessing the String's Characters
- Finding a Substring within a String
- Extracting Part of the String
- Splitting a String
- Joining a String
- Uppercasing and Lowercasing
- Formatting Strings
- Finishing the Sample Application
- Representing Objects as Strings
- Allocating Strings with StringBuilder
Uppercasing and Lowercasing
You can easily produce a version of a string where all the characters are uppercase or all the characters are lowercase.
To produce a string in either uppercase or lowercase form:
Declare a new string variable.
Type = str.ToUpper(); or = str.ToLower() accordingly, where str is a variable holding the original string (Figure 4.55).
Figure 4.55 The ToUpper function creates a new string object from the original where all characters are in uppercase.
Tip
The ToUpper and ToLower functions don't change the original string. They produce new strings (and therefore new string buffers) with the characters' case modified.