ToString Method
Collapse the table of content
Expand the table of content

TextInfo.ToString Method

[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]

Returns a string that represents the current TextInfo.

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

public override string ToString()

Return Value

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

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.

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.


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   


Windows Phone OS

Supported in: 8.1, 8.0, 7.1, 7.0

Windows Phone

Show:
© 2017 Microsoft