Daniel S
0
Q:

c# array.join

List<string> names = new List<string>() { "John", "Anna", "Monica" };
var result = String.Join(", ", names.ToArray());
3
// C# program to demonstrate the 
// Join(String, Obj [ ]) method 
using System; 
namespace ConsoleApplication1 { 
  
class Geeks { 
      
    // Main Method 
    static void Main(string[] args) 
    { 
  
        // Creating an object array 
        // Here, It is consist of four  
        // elements only 
        object[] array = {"Hello", "Geeks", 12345, 786}; 
  
        // Using Join method 
        // Here separator is ', '( comma ) 
        string s1 = string.Join(", ", array); 
  
        // Finally after joining process gets over 
        // Getting the output of value of string s1 
        Console.WriteLine("Value of string  s1 is " + s1); 
    } 
} 
} 
1
var combined = String.Join(",", new String[]{"a","b"});
// a,b
3
using System;
public class Demo {
   public static void Main(string[] args) {
      string[] strArr = {"AB", "BC", "CD", "DE", "EF", "FG", "GH", "IJ" };
      Console.WriteLine("String Array...");
      foreach(string s in strArr) {
         Console.WriteLine(s);
      }
      string str = string.Join("*", strArr);
      Console.WriteLine("Result (after joining) = " + str);
   }
}
0
String Array...
AB
BC
CD
DE
EF
FG
GH
IJ
Result (after joining) = AB*BC*CD*DE*EF*FG*GH*IJ
-1

New to Communities?

Join the community