Convert.ToString Method (String)

 

Returns the specified string instance; no actual conversion is performed.

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

Public Shared Function ToString (
	value As String
) As String

Parameters

value
Type: System.String

The string to return.

Return Value

Type: System.String

value is returned unchanged.

The following example passes a string to the ToString(String) method and calls the Object.ReferenceEquals method to confirm that the method returns the original string. The example also calls the String.IsInterned method to ensure that the two strings are not identical because the original string is interned.

Module Example
   Public Sub Main()
      Dim article As String = "An"
      Dim noun As String = "apple"
      Dim str1 As String = String.Format("{0} {1}", article, noun)
      Dim str2 As String = Convert.ToString(str1)

      Console.WriteLine("str1 is interned: {0}",
                        Not String.IsInterned(str1) Is Nothing)
      Console.WriteLine("str1 and str2 are the same reference: {0}",
                        Object.ReferenceEquals(str1, str2))
   End Sub
End Module
' The example displays the following output:
'       str1 is interned: False
'       str1 and str2 are the same reference: True

.NET Framework
Available since 1.1
Return to top
Show: