String.Concat Method (Object, Object)

Updated: October 2010

Concatenates the string representations of two specified objects.

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

Public Shared Function Concat ( _
	arg0 As Object, _
	arg1 As Object _
) As String


Type: System.Object
The first object to concatenate.
Type: System.Object
The second object to concatenate.

Return Value

Type: System.String
The concatenated string representations of the values of arg0 and arg1.

The method concatenates arg0 and arg1 by calling the parameterless ToString method of arg0 and arg1; it does not add any delimiters.

String.Empty is used in place of any null argument.

If either of the arguments is an array reference, the method concatenates a string representing that array, instead of its members (for example, "System.String[]").

The following code example demonstrates the Concat method.


Class Example

   Public Shared Sub Demo(ByVal outputBlock As System.Windows.Controls.TextBlock)
      Dim i As Integer = -123
      Dim o As [Object] = i
      Dim objs() As [Object] = {-123, -456, -789}

      outputBlock.Text += String.Format("Concatenate 1, 2, and 3 objects:") & vbCrLf
      outputBlock.Text += String.Format("1) {0}", [String].Concat(o)) & vbCrLf
      outputBlock.Text += String.Format("2) {0}", [String].Concat(o, o)) & vbCrLf
      outputBlock.Text += String.Format("3) {0}", [String].Concat(o, o, o)) & vbCrLf

      outputBlock.Text &= vbCrLf & "Concatenate 4 objects and a variable length parameter list:" & vbCrLf
      outputBlock.Text += String.Format("4) {0}", [String].Concat(o, o, o, o, o)) & vbCrLf

      outputBlock.Text &= vbCrLf & "Concatenate a 3 element object array:" & vbCrLf
      outputBlock.Text += String.Format("5) {0}", [String].Concat(objs)) & vbCrLf
   End Sub 'Main
End Class 'stringConcat5
'This example produces the following output:
'Concatenate 1, 2, and 3 objects:
'1) -123
'2) -123-123
'3) -123-123-123
'Concatenate 4 objects and a variable length parameter list:
'4) -123-123-123-123-123
'Concatenate a 3 element object array:
'5) -123-456-789


Supported in: 5, 4, 3

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0

XNA Framework

Supported in: Xbox 360, Windows Phone OS 7.0

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.




October 2010

Revised the Remarks section.

Customer feedback.