String Concatenation C# with Example



String Concatenation C# with Example

String Concatenation can be done by using the System.String.Concat method, or (much easier) using the + 
operator: 
string first = "Hello "; 
string second = "World"; 
string concat = first + second; // concat = "Hello World" 
concat = String.Concat(first, second); //  concat =  "Hello  World" 
In C# 6 this can be done as follows: 
string concat = $"{first},{second}"; 
 

Parameter Details 
format A composite format string, which defines the way args should be combined into a string. 
A sequence of objects to be combined into a string. Since this uses a params argument, you can either 
args 
use a comma-separated list of arguments or an actual object array. 
A collection of ways of formatting objects to strings. Typical values include CultureInfo.InvariantCulture 
provider 
and CultureInfo.CurrentCulture. 
The Format methods are a set of overloads in the System.String class used to create strings that combine objects 
into specific string representations. This information can be applied to String.Format, various WriteLine methods 
as well as other methods in the .NET framework. 

0 Comment's

Comment Form

Submit Comment