Convert.ToString Method (String)


The .NET API Reference documentation has a new home. Visit the .NET API Browser on to see the new experience.

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

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

public static string ToString(
	string 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.

using System;

public class Example
   public static void Main()
      String article = "An";
      String noun = "apple";
      String str1 = String.Format("{0} {1}", article, noun);
      String str2 = Convert.ToString(str1);

      Console.WriteLine("str1 is interned: {0}",
                        ! (String.IsInterned(str1) == null));
      Console.WriteLine("str1 and str2 are the same reference: {0}",
                        Object.ReferenceEquals(str1, str2));
// 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