Concatenate various values as string in CSharp

Description

The following code shows how to concatenate various values as string.

Example


 //www.j a v  a2  s  . c o  m
 
using System; 
 
public class ConcatDemo { 
  public static void Main() { 
 
    string result = String.Concat("hi ", 10, " ", 
                                   20.0, " ", 
                                   false, " ", 
                                   23.45M); 
 
    Console.WriteLine("result: " + result); 
  } 
}

The code above generates the following result.





















Home »
  C# Tutorial »
    Data Types »




C# Data Types
Bool
Byte
Char
Decimal
Double
Float
Integer
Long
Short
String
C# Array
Array Example
Byte Array
C# Standard Data Type Format
BigInteger
Complex
Currency
DateTime
DateTimeOffset
DateTime Format Parse Convert
TimeSpan
TimeZone
Enum
Null
tuple
var