Introduction:

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

Description:

In c# programming language Join() method is a string method, the Join() method is used to concatenate all the elements of string array using specified separator between each element.

C# String Join Method Example

 

Following is the example of using Join() method to append or concatenate all string array elements using specified separator in c# programming language.

 

using System;
namespace SQLTutorialsPoint
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] sArr = { "Welcome", "to", "SQL Tutorials Point" };
            Console.WriteLine("Join with Hypen: {0}", string.Join("-", sArr));
            string[] sArr1 = { "Aditya", "Komal", "Pawan" };
            Console.WriteLine("Join with Comma: {0}", string.Join(", ", sArr1));
            Console.WriteLine("\nPress Enter Key to Exit..");
            Console.ReadLine();
        }
    }
}

As you see above example, we used a string Join() method to append or concatenate all the elements of string array using specified separator.

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

 How to use String Join Method in c#

 

In this article we have learned, how we can use string Join() method to append or concatenate all string array elements using specified separator 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