Learnerslesson
   JAVA   
  SPRING  
  SPRINGBOOT  
 HIBERNATE 
  HADOOP  
   HIVE   
   ALGORITHMS   
   PYTHON   
   GO   
   KOTLIN   
   C#   
   RUBY   
   C++   




Join() - Method


Join() Method


The Join() Method is used to join all the elements of an array into one string.


Example :



public class MyApplication
{
    public static void Main(string[] args)
    {
       	string[] x = {"Hello", "Beautiful", "World"};
	    string y = string.Join("@", x);
        System.Console.WriteLine(y);
     }
}


Output :



  Hello@Beautiful@World

In the above code, we have declared an array with values Hello, Beautiful and World. And assigned it to a variable x.


string[] x = {"Hello", "Beautiful", "World"};
C_Sharp


Then we have used the Join() function to take all the three values from the array and join them, separated using @.


string y = string.Join("@", x);
C_Sharp