find and solve || findandsolve.com
Please wait.....

C# String Join()

Join() is a string method in c#. Join method is used to concatenate the elements of an array, using the specified separator between each element. It returns a modified string.

Synax

[ComVisibleAttribute(false)]  
public static string Join(String first, params String[] second)
[ComVisibleAttribute(false)]
public static string Joint(String, params Object[])
[ComVisibleAttribute(false)] public static string Join (String, IEnumerable<String>)
[ComVisibleAttribute(false)]
public static string Join(String, String[], Int32, Int32)
[ComVisibleAttribute(false)]
public static string Join<T>(String, IEnumerable <T>)  

Parameter

first: it is a string type parameter.

second: it is a string array.

Return

It returns a string.

Example

using System;
public class Program
{
    // Main Method
    public static void Main(string[] args)
    {
      string[] str = {"Hello","C#","by","FindAndSolve"};
      string str2 = string.Join("-",str);
      Console.WriteLine(str2);
    }
}

Output

Hello-C#-by-FindAndSolve