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.4. string Indexer, Length Property and CopyTo Method

The app in Fig. 16.2 presents the string indexer, which facilitates the retrieval of any character in the string, and the string property Length, which returns the length of the string. The string method CopyTo copies a specified number of characters from a string into a char array.

  1   // Fig. 16.2: StringMethods.cs   2   // Using the indexer, property Length and method CopyTo   3   // of class string.   4   using System;   5   6   class StringMethods   7   {   8      public static void Main( string[] args )   9      {  10         string string1 = "hello there";  11         char[] characterArray = new char[ 5 ];  12  13         // output string1  14         Console.WriteLine( ...

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