String.Concat Method (String, String, String)

Concatenates three specified instances of String.

Namespace:  System
Assembly:  mscorlib (in mscorlib.dll)

'Declaration
Public Shared Function Concat ( _
	str0 As String, _
	str1 As String, _
	str2 As String _
) As String

Parameters

str0
Type: System.String

The first string to concatenate.

str1
Type: System.String

The second string to concatenate.

str2
Type: System.String

The third string to concatenate.

Return Value

Type: System.String
The concatenation of str0, str1, and str2.

The method concatenates str0, str1, and str2; it does not add any delimiters.

An Empty string is used in place of any null argument.

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

Option Explicit
Option Strict

Imports System
Imports System.Globalization

Public Class MainClass

    Public Shared Sub Main()
        Dim dt As DateTime = DateTime.Now
        Dim myformat() As String =  {"d", "D", _
                                    "f", "F", _
                                    "g", "G", _
                                    "m", _
                                    "r", _
                                    "s", _
                                    "t", "T", _
                                    "u", "U", _
                                    "y", _
                                    "dddd, MMMM dd yyyy", _
                                    "ddd, MMM d ""'""yy", _
                                    "dddd, MMMM dd", _
                                    "M/yy", _
                                    "dd-MM-yy"}
        Dim mydate As String 
        Dim i As Integer 
        For i = 0 To myformat.Length - 1
            mydate = dt.ToString(myformat(i), DateTimeFormatInfo.InvariantInfo)
            Console.WriteLine(String.Concat(myformat(i), " :", mydate))
        Next i

    ' Output. 
    
    ' d :08/17/2000 
    ' D :Thursday, August 17, 2000 
    ' f :Thursday, August 17, 2000 16:32 
    ' F :Thursday, August 17, 2000 16:32:32 
    ' g :08/17/2000 16:32 
    ' G :08/17/2000 16:32:32 
    ' m :August 17 
    ' r :Thu, 17 Aug 2000 23:32:32 GMT 
    ' s :2000-08-17T16:32:32 
    ' t :16:32 
    ' T :16:32:32 
    ' u :2000-08-17 23:32:32Z 
    ' U :Thursday, August 17, 2000 23:32:32 
    ' y :August, 2000 
    ' dddd, MMMM dd yyyy :Thursday, August 17 2000 
    ' ddd, MMM d "'"yy :Thu, Aug 17 '00 
    ' dddd, MMMM dd :Thursday, August 17 
    ' M/yy :8/00 
    ' dd-MM-yy :17-08-00 
    End Sub 'Main 
End Class 'MainClass

.NET Framework

Supported in: 4.5, 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Portable Class Library

Supported in: Portable Class Library

.NET for Windows Store apps

Supported in: Windows 8

.NET for Windows Phone apps

Supported in: Windows Phone 8.1, Windows Phone Silverlight 8.1, Windows Phone Silverlight 8

Windows Phone 8.1, Windows Phone 8, Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft