System.String.Concat Method
The String.Concat method concatenates one or more strings.
Namespace
System
Assembly
System.Runtime.dll
Syntax
public static string Concat(params string?[]? values);
public static string Concat(string? str0, string? str1);
public static string Concat(string? str0, string? str1, string? str2);
public static string Concat(string? str0, string? str1, string? str2, string? str3);
public static string Concat(string? str0, string? str1, string? str2, string? str3, string? str4);
public static string Concat(IEnumerable<string?>? values);
Parameters
- values – An array of strings to concatenate.
- str0‑str4 – Individual string arguments to concatenate.
- values – A collection of strings to concatenate.
Return Value
A String that is the concatenation of the input strings, or String.Empty if all inputs are null.
Remarks
Concat is optimized for concatenating a small number of strings. For large collections, consider using StringBuilder.
Examples
Concatenating several strings:
string result = String.Concat("Hello", ", ", "World", "!");
// result => "Hello, World!"
Concatenating an array of strings:
string[] parts = { "One", "Two", "Three" };
string result = String.Concat(parts);
// result => "OneTwoThree"