C# String Concat(String, String, String)

Description

String Concat(String, String, String) concatenates three specified instances of String.

Syntax

String.Concat(String, String, String) has the following syntax.


public static string Concat(
  string str0,/* w  ww .  java  2s .co m*/
  string str1,
  string str2
)

Parameters

String.Concat(String, String, String) has the following parameters.

  • str0 - The first string to concatenate.
  • str1 - The second string to concatenate.
  • str2 - The third string to concatenate.

Returns

String.Concat(String, String, String) method returns The concatenation of str0, str1, and str2.

Example

In the following example, the output to the console is generated using this Concat method.


//from  w w  w.j av a 2 s  .  c o m
using System;
using System.Globalization; 

public class MainClass { 
    public static void Main(string[] args)  {
        DateTime dt = DateTime.Now;
        String[] format = {
            "dddd, MMMM dd yyyy",
            "ddd, MMM d \"'\"yy",
            "dddd, MMMM dd",
            "M/yy",
            "dd-MM-yy",
        };
        String date;
        for (int i = 0; i < format.Length; i++) {
            date = dt.ToString(format[i], DateTimeFormatInfo.InvariantInfo);
            Console.WriteLine(String.Concat(format[i], " :" , date));
        }
    }
}

The code above generates the following result.





















Home »
  C# Tutorial »
    System »




Array
BitConverter
Boolean
Byte
Char
Console
ConsoleKeyInfo
Convert
DateTime
DateTimeOffset
Decimal
Double
Enum
Environment
Exception
Guid
Int16
Int32
Int64
Math
OperatingSystem
Random
SByte
Single
String
StringComparer
TimeSpan
TimeZone
TimeZoneInfo
Tuple
Tuple
Tuple
Type
UInt16
UInt32
UInt64
Uri
Version