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.3. string Constructors

Class string provides eight constructors for initializing strings in various ways. Figure 16.1 demonstrates three of the constructors.

 1   // Fig. 16.1: StringConstructor.cs  2   // Demonstrating string class constructors.  3   using System;  4  5   class StringConstructor  6   {  7      public static void Main( string[] args )  8      {  9         // string initialization                              10         char[] characterArray =                               11            { 'b', 'i', 'r', 't', 'h', ' ', 'd', 'a', 'y' };   12         string originalString = "Welcome to C# programming!"; 13         string string1 = originalString;                      14         string string2 = ...

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