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 ).

    Figure 4.55 The ToUpper function creates a new string object from the original where all characters are in uppercase.
     string msg= "When are you going to be done?";  string screamMsg = msg.ToUpper();  /* outputs: WHEN ARE YOU GOING TO BE DONE? */ 

graphics/tick.gif 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.




C#
C# & VB.NET Conversion Pocket Reference
ISBN: 0596003196
EAN: 2147483647
Year: 2003
Pages: 198
Authors: Jose Mojica

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net