C# String Concat(Object, Object, Object, Object)
Description
String Concat(Object, Object, Object, Object)
concatenates
the string representations of four specified objects and any objects specified
in an optional variable length parameter list.
Syntax
String.Concat(Object, Object, Object, Object)
has the following syntax.
C# does not support methods that use variable length arguments (varargs).
The compiler automatically resolves calls to this method to the same method that uses a parameter array.
Parameters
String.Concat(Object, Object, Object, Object)
has the following parameters.
arg0
- The first object to concatenate.arg1
- The second object to concatenate.arg2
- The third object to concatenate.arg3
- The fourth object to concatenate.
Returns
String.Concat(Object, Object, Object, Object)
method returns The concatenated string representation of each value in the parameter list.
Example
The following example illustrates the use of the Concat(Object, Object, Object, Object) method to concatenate a list of variable parameters.
//from w w w .j ava2s . c om
using System;
using System.Collections;
public class Example
{
public static void Main()
{
string[] words = { "A", "B", "C", "D" };
string scrambledWord = String.Concat(words[0], words[1],
words[2], words[3]);
Console.WriteLine(scrambledWord);
}
}
The code above generates the following result.