concatenar string C# code example

Example 1: c# string concatenation

string userName = "<Type your name here>";
string dateString = DateTime.Today.ToShortDateString();

// Use the + and += operators for one-time concatenations.
string str = "Hello " + userName + ". Today is " + dateString + ".";
System.Console.WriteLine(str);

str += " How are you today?";
System.Console.WriteLine(str);

Example 2: c# diferença em stringbuilder e contatenação

var nomesDosAlunos = new StringBuilder();
foreach(var aluno in salaDeAula.Alunos)
    nomesDosAlunos.Append(aluno.Nome).Append(',');

Example 3: c# Add or Concatenate Strings In C#

string str1 = "ppp";  
string strRes = str1.Insert(2, "bbb");  
Console.WriteLine(strRes.ToString());