Manipulating Strings in C#—Uppercasing and Lowercasing

Microsoft .NET Framework, ASP.NET, Visual C# (CSharp, C Sharp, C-Sharp) Developer Training, Visual Studio


Jump to: navigation, search
CSharp-Online.NET:Articles
C# Articles

Manipulating Strings in C#

© 2003 Peachpit Press

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:

1. Declare a new string variable.
2. Type = str.ToUpper(); or = str.ToLower() accordingly, where str is a variable holding the original string (Figure 4.55).


Image:CSharpWebDevASPNET4-55.gif
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.


Previous_Page_.gif Next_Page_.gif


Personal tools