Introduction:

In this article we will explain how to use string Concat method or what is string Concat method in c# with example.

Description:

In c# programming language string concat() method is a string method, the concat()  method is used to append one string to the end of another string  and return a new string.


C# String Concat Method Syntax

Following is the example of using Concat() method to append or concatenate one or more  string  and return it as new string  in c# programming language.

 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace SQLTutorialsPoint
{
    class Program
    {
        static void Main(string[] args)
        {
            string msg1 = "Welcome to";
            string msg2 = " " + "Sqltutorialspoint.com";
            Console.WriteLine("Message:{0}",         string.Concat(msg1,msg2));
            string name1 = "Aditya";
            string name2 = ", " + "pawan";
            string name3 = ", " + "manoj";
            Console.WriteLine("Users:{0}",         string.Concat(string.Concat(name1,name2), name3));
            Console.WriteLine("\nPress Enter Key to Exit..");
            Console.ReadLine();
        }
    }
}

As you see above example, we used a Concat() method to append multiple strings and returning it as a new string.

 

When we execute above c# program, we will get the result like as shown below.

 how to use string Concat method in C# with example

 

In this article we have learned. How we can use Concat() method to append or concatenate one or more string into one string in c# programming language.


I hope it will help to you after reading.

0 comments


Leave a comment

Make sure you enter the (*) required information where indicated. HTML code is not allowed.

You may also like