String Concatenation

String Interpolation

In C#, string concatenation can be done using the + operator or the string.Concat method. Here’s how to use both:

Using the + operator:

				
					string str1 = "Hello";
string str2 = "world";
string result = str1 + " " + str2;
Console.WriteLine(result); // Output: "Hello world"

				
			

Using the string.Concat method:

				
					string str1 = "Hello";
string str2 = "world";
string result = string.Concat(str1, " ", str2);
Console.WriteLine(result); // Output: "Hello world"

				
			
Join To Get Our Newsletter
Spread the love