C# String Join(String, Object[])
Description
String Join(String, Object[])
concatenates the elements
of an object array, using the specified separator between each element.
Syntax
String.Join(String, Object[])
has the following syntax.
[ComVisibleAttribute(false)]/* w w w . j a va 2 s .co m*/
public static string Join(
string separator,
params Object[] values
)
Parameters
String.Join(String, Object[])
has the following parameters.
separator
- The string to use as a separator. separator is included in the returned string only if values has more than one element.values
- An array that contains the elements to concatenate.
Returns
String.Join(String, Object[])
method returns A string that consists of the elements of values delimited by the separator
string. If values is an empty array, the method returns String.Empty.
Example
//w w w . j a v a2 s. c om
using System;
public class MainClass{
public static void Main(String[] argv){
object[] values = { null, "Java2s.com", 1234, 11434, .366 };
if (values[0] == null) values[0] = String.Empty;
Console.WriteLine(String.Join("|", values));
}
}
The code above generates the following result.