O'Reilly logo

Visual C#® 2012: How to Program, Fifth Edition by Harvey Deitel, Paul Deitel

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

16.9. Miscellaneous string Methods

Class string provides several methods that return modified copies of strings. The app in Fig. 16.8 demonstrates the use of these methods, which include string methods Replace, ToLower, ToUpper and Trim.

 1   // Fig. 16.8: StringMethods2.cs  2   // Demonstrating string methods Replace, ToLower, ToUpper, Trim,  3   // and ToString.  4   using System;  5  6   class StringMethods2  7   {  8      public static void Main( string[] args )  9      { 10         string string1 = "cheers!"; 11         string string2 = "GOOD BYE "; 12         string string3 = "   spaces  "; 13 14         Console.WriteLine( "string1 = \"" + string1 + "\"\n" + 15            "string2 = \"" + string2 + "\"\n" ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required