C# String Concat() Method

Beginner
5 min read
Updated: Nov 2026
3 examples
String

Definition

In C#, String.Concat() joins strings into one new string. It does not insert a separator between pieces.

You pass the pieces to join. At least one value is required in normal use. The inputs are not changed. The result is a new string.

Syntax

Pass the pieces to join. Start with this call.

C#
string s = string.Concat("Code", "To", "Fun");
CallWhat it does
string.Concat("Code", "To", "Fun")Joins the pieces into CodeToFun with no spaces.

This is a static method. For a separator between items, use string.Join.

Library declarations
C#
public static string Concat(string str0, string str1);
public static string Concat(params string[] values);

Parameters

ParameterDescription
str0Required. The first string.
str1Required. The second string.
valuesOptional. More strings when you use the params overload.

Return Value

Return ValueDescription
New stringThe joined text. Empty pieces become empty text.

C# Examples

Example 1 — Join First and Last Name

Build a full name with an explicit space separator between two strings.

C#
using System;

class Program {
    static void Main() {
        string first = "John";
        string last  = "Doe";

        string fullName = string.Concat(first, " ", last);

        Console.WriteLine(fullName);
        Console.WriteLine($"first still: {first}");
    }
}

How It Works

  1. Call the static method. string.Concat(first, " ", last) joins three pieces in order.
  2. Include the separator. The space is its own argument—Concat does not insert separators automatically.
  3. Get a new string. fullName is "John Doe".
  4. Inputs stay unchanged. first is still "John" because strings are immutable.

Example 2 — Concat an Array (or params)

Pass a string[] or several arguments—both join left to right with no separator between items.

C#
using System;

class Program {
    static void Main() {
        string[] parts = { "Code", "To", "Fun" };

        string glued = string.Concat(parts);
        string spaced = string.Concat(parts[0], " ", parts[1], " ", parts[2]);

        Console.WriteLine(glued);
        Console.WriteLine(spaced);
    }
}

How It Works

  1. Array overload. Concat(parts) joins every element with nothing between → "CodeToFun".
  2. Add spaces yourself. Pass separators as extra arguments when you need gaps.
  3. Need commas between items? Prefer string.Join(", ", parts)—built for delimiters.
  4. Params works the same. Concat("A", "B", "C") is equivalent to joining those three strings.

Example 3 — Null Becomes Empty

null string arguments are skipped as empty text—safe, but easy to miss when debugging missing words.

C#
using System;

class Program {
    static void Main() {
        string middle = null;

        string result = string.Concat("Hello", middle, "!");

        Console.WriteLine(result);
        Console.WriteLine($"Length: {result.Length}");
    }
}

How It Works

  1. Pass null in the middle. middle is null.
  2. Concat substitutes empty. "Hello" + "" + "!" → "Hello!".
  3. No exception. Unlike some APIs, Concat does not throw on null string args.
  4. Watch missing text. If a name is unexpectedly blank, check for null inputs—not a printed "null".

Frequently Asked Questions

Concat() joins strings into one new string with no separator.
Pass the strings to join. Common overloads take two strings or a params array.
A new string with all pieces joined.
No. Strings are immutable. The inputs stay the same.
Use string.Join(separator, values) when you need commas or spaces between items.

Next: Contains()

Learn how to check whether a string contains a substring.

Contains() tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

9 people found this page helpful