About This eBook by Bart De Smet

Safari, the world’s most comprehensive technology and business learning platform.

Find the exact information you need to solve a problem on the fly, or go deeper to master the technologies and skills you need to succeed

Start Free Trial

No credit card required

O'Reilly logo

String Concatenation

Syntactically closely related to arithmetic operations is string concatenation, reusing the + operator notation. The following is an example:

Console.Write("Enter your name: ");string name = Console.ReadLine();string message = "Hello " + name;Console.WriteLine(message);

The way concatenation works internally is by calling into any of the String.Concat static methods, as shown in Figure 5.17.

Image

FIGURE 5.17 String concatenation under the hood.

String concatenation is available not only between two string types but also between a string and any object (System.Object). In that case, ToString is invoked on the object before carrying ...

Find the exact information you need to solve a problem on the fly, or go deeper to master the technologies and skills you need to succeed

Start Free Trial

No credit card required