String.ToString Method

Returns this instance of the string; no actual conversion is performed.

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

'Declaration
Public Overrides Function ToString As String

Return Value

Type: System.String
The current string.

The following code example demonstrates the ToString method.


 _

Class Example

   Public Shared Sub Demo(ByVal outputBlock As System.Windows.Controls.TextBlock)
      Dim str1 As [String] = "123"
      Dim str2 As [String] = "abc"

      outputBlock.Text += String.Format("Original str1: {0}", str1) & vbCrLf
      outputBlock.Text += String.Format("Original str2: {0}", str2) & vbCrLf
      outputBlock.Text += String.Format("str1 same as str2?: {0}", [Object].ReferenceEquals(str1, str2)) & vbCrLf

      str2 = str1.ToString()
      outputBlock.Text &= vbCrLf
      outputBlock.Text += String.Format("New str2:      {0}", str2) & vbCrLf
      outputBlock.Text += String.Format("str1 same as str2?: {0}", [Object].ReferenceEquals(str1, str2)) & vbCrLf
   End Sub 'Main
End Class 'Sample
'
'This code produces the following output:
'Original str1: 123
'Original str2: abc
'str1 same as str2?: False
'
'New str2:      123
'str1 same as str2?: True
'


Silverlight

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.

Community Additions

ADD
Show: