By 22/07/2015 6 Comments

C# Concatenation Operator

  • It is denoted by a + plus sign and can be called concatenation operator.
  • It is used to join or connect one string value with another string or multiple strings each other.
  • It is also used to join a non-string value with a string value.
  • It is performed at compile time by C# compiler.
  • The concatenation (+) operator is converted into string.Concat method at compile time.

Example:

using System;
namespace csharpBasic
{
  // Start class definition / declaration.
    class Program
    {
      // Static main method void type declaration.
        static void Main(string[] args)
        {
            // Declare two string type variables.
            string technologyName, designPattern;

            // Initialize string variables with different values.
            technologyName = "C# .NET is an ";
            designPattern = "Object oriented programing language.";

            // Print string variables. 
            Console.WriteLine(technologyName + designPattern);

            // Declare and initialize pi variable with 3.14 value.
            double pi = 3.14;

            // Print pi value.
            Console.WriteLine("In mathematics the value of Pi is " + pi);
            Console.ReadKey();

        } // End of main method definition.

    } // End of class.
}

Remember:

  • Concatenation operator (+) can be applied on any data type.
  • It joins strings to any data type.





Next Tutorial →


← Previous Tutorial


Posted in: C# Basics, C#.NET

Leave your valuable Comment

Have a natural attraction for women cosmetics and replica watches uk clothes, no
more than two for men the most attractive one, is to make their own driving experience, happy and can serve as the facade of the car, another is to highlight the taste edify sentiment rolex replica watch. The replica rolex is undoubtedly the most fashionable accessories, wear a suit to attend the activities, but also get a decent match on the replica watches .