How to use C# string Concat

Within the C# String Class, the Concat method assumes a crucial role in facilitating the process of string concatenation. By invoking this method, developers can seamlessly combine and merge two specified strings, culminating in the creation of a new string that encompasses the combined content of both source strings.

The Concat method operates by effectively joining the textual contents of the specified strings, thereby establishing a unified and cohesive result. This cohesive outcome represents the culmination of the concatenated strings, presenting a brand new string object that encapsulates the combined essence of the original inputs.

string concat(string str1,string str2)

String Concat method returns a new String

  1. String str1 : Parameter String
  2. String str2 : Parameter String
  1. String : A new String return with str1 Concat with str2

String Concat method

Using the Concat method within the C# String Class, programmers can harmoniously merge and unify textual information, transcending the limitations imposed by individual strings. This functionality facilitates the generation of a new string that embodies the collective elements of the source strings, effectively expanding the possibilities for data manipulation and information representation.

Full Source C#
using System; using System.Windows.Forms; namespace WindowsApplication1 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { string str1 = null; string str2 = null; str1 = "Concat() "; str2 = "Test"; MessageBox.Show(string.Concat(str1, str2)); } } }

When you run this C# source code you will get "Concat() Test " in message box.


Through the utilization of the Concat method, developers are empowered to harness the expressive potential of string concatenation, enabling the seamless merging of disparate strings to create a consolidated and comprehensive representation. This mechanism facilitates efficient data handling and streamlined information management within the C# programming paradigm, ultimately contributing to the development of robust and effective software applications.