Share via


TextInfo.ToString Method

Microsoft Silverlight will reach end of support after October 2021. Learn more.

Returns a string that represents the current TextInfo.

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

Syntax

'Declaration
Public Overrides Function ToString As String
public override string ToString()

Return Value

Type: System.String
A string that represents the current TextInfo.

Remarks

This method overrides Object.ToString. It displays the name of the object, followed by a hyphen, followed by the name of the culture whose writing system the TextInfo object represents.

Examples

The following example calls the ToString method for TextInfo objects that represent the writing systems of several different cultures. The current system culture for the example is en-US.

Imports System.Globalization

Public Module Example
   Private outputBlock As System.Windows.Controls.TextBlock

   Public Sub Demo(ByVal outBlock As System.Windows.Controls.TextBlock)
      outputBlock = outBlock

      ShowTextInfoName(CultureInfo.CurrentCulture.TextInfo)
      ShowTextInfoName(CultureInfo.InvariantCulture.TextInfo)
      ShowTextInfoName((New CultureInfo("en")).TextInfo)
      ShowTextInfoName((New CultureInfo("fr-FR")).TextInfo)
      ShowTextInfoName((New CultureInfo("de-DE")).TextInfo)
   End Sub 

   Private Sub SHowTextInfoName(txt As TextInfo)
      outputBlock.Text &= txt.ToString() & vbCrLf
   End Sub   
End Module
' The example displays the following output:
'     TextInfo - en-US
'     TextInfo - 
'     TextInfo - en
'     TextInfo - fr-FR
'     TextInfo - de-DE   
using System;
using System.Globalization;

public class Example
{
   private static System.Windows.Controls.TextBlock outputBlock;

   public static void Demo(System.Windows.Controls.TextBlock outBlock)
   {
      outputBlock = outBlock;

      ShowTextInfoName(CultureInfo.CurrentCulture.TextInfo);
      ShowTextInfoName(CultureInfo.InvariantCulture.TextInfo);
      ShowTextInfoName((new CultureInfo("en")).TextInfo);
      ShowTextInfoName((new CultureInfo("fr-FR")).TextInfo);
      ShowTextInfoName((new CultureInfo("de-DE")).TextInfo);
   } 

   private static void ShowTextInfoName(TextInfo txt)
   {
      outputBlock.Text += txt.ToString() + "\n";
   }
}
//     TextInfo - en-US
//     TextInfo - 
//     TextInfo - en
//     TextInfo - fr-FR
//     TextInfo - de-DE   

Version Information

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

Platforms

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