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.7. Extracting Substrings from strings

Class string provides two Substring methods, which create a new string by copying part of an existing string. Each method returns a new string. The app in Fig. 16.6 demonstrates the use of both methods.

 1   // Fig. 16.6: SubString.cs  2   // Demonstrating the string Substring method.  3   using System;  4  5   class SubString  6   {  7      public static void Main( string[] args )  8      {  9         string letters = "abcdefghijklmabcdefghijklm"; 10 11         // invoke Substring method and pass it one parameter 12         Console.WriteLine( "Substring from index 20 to end is \"" + 13            letters.Substring( 20 ) + "\"" ); 14 15         // invoke Substring method ...

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