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.8. Concatenating strings

The + operator is not the only way to perform string concatenation. The static method Concat of class string (Fig. 16.7) concatenates two strings and returns a new string containing the combined characters from both original strings. Line 16 appends the characters from string2 to the end of a copy of string1, using method Concat. The statement in line 16 does not modify the original strings.

 1   // Fig. 16.7: SubConcatenation.cs  2   // Demonstrating string class Concat method.  3   using System;  4  5   class StringConcatenation  6   {  7      public static void Main( string[] args )  8      {  9         string string1 = "Happy "; 10         string string2 = "Birthday"; 11 12         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