共用方式為


CultureInfo.TextInfo Property

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

Gets the TextInfo object that defines the writing system associated with the culture.

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

Syntax

'Declaration
Public Overridable ReadOnly Property TextInfo As TextInfo
public virtual TextInfo TextInfo { get; }

Property Value

Type: System.Globalization.TextInfo
The TextInfo object that defines the writing system associated with the culture.

Remarks

The TextInfo property returns a TextInfo object that provides culture-specific casing information for strings. To perform culture-insensitive casing, the application should use the TextInfo property of the CultureInfo.InvariantCulture object.

Examples

The following example shows how to create two es-ES CultureInfo objects: one with the international sort order and another with the traditional sort order.

Imports System.Globalization

Public Module Example
   Public Sub Demo(outputBlock As System.Windows.Controls.TextBlock)
      outputBlock.FontFamily = New FontFamily("Courier New")

      ' Create and initialize an es-ES CultureInfo object with the international sort order.
      Dim ciIntl As New CultureInfo("es-ES")

      ' Create and initialize an es-ES CultureInfo object with the traditional sort order.
      Dim ciTrad As New CultureInfo("es-ES_tradnl")

      ' Display the properties of each culture.
      outputBlock.Text += String.Format("{0,-28}{1,-35}{2,-35}", "PROPERTY", "INTERNATIONAL", "TRADITIONAL") + vbCrLf
      outputBlock.Text += String.Format("{0,-28}{1,-35}{2,-35}", "CompareInfo", ciIntl.CompareInfo, ciTrad.CompareInfo) + vbCrLf
      outputBlock.Text += String.Format("{0,-28}{1,-35}{2,-35}", "DisplayName", ciIntl.DisplayName, ciTrad.DisplayName) + vbCrLf
      outputBlock.Text += String.Format("{0,-28}{1,-35}{2,-35}", "EnglishName", ciIntl.EnglishName, ciTrad.EnglishName) + vbCrLf
      outputBlock.Text += String.Format("{0,-28}{1,-35}{2,-35}", "Name", ciIntl.Name, ciTrad.Name) + vbCrLf
      outputBlock.Text += String.Format("{0,-28}{1,-35}{2,-35}", "NativeName", ciIntl.NativeName, ciTrad.NativeName) + vbCrLf
      outputBlock.Text += String.Format("{0,-28}{1,-35}{2,-35}", "Parent", ciIntl.Parent, ciTrad.Parent) + vbCrLf
      outputBlock.Text += String.Format("{0,-28}{1,-35}{2,-35}", "TextInfo", ciIntl.TextInfo, ciTrad.TextInfo) + vbCrLf
      outputBlock.Text += String.Format("{0,-28}{1,-35}{2,-35}", "TwoLetterISOLanguageName", ciIntl.TwoLetterISOLanguageName, ciTrad.TwoLetterISOLanguageName) + vbCrLf
      outputBlock.Text += vbCrLf

      ' Compare two strings using ciIntl.
      outputBlock.Text += String.Format("Comparing ""llegar"" and ""lugar""") + vbCrLf
      outputBlock.Text += String.Format("   With ciIntl.CompareInfo.Compare: {0}", ciIntl.CompareInfo.Compare("llegar", "lugar")) + vbCrLf
      outputBlock.Text += String.Format("   With ciTrad.CompareInfo.Compare: {0}", ciTrad.CompareInfo.Compare("llegar", "lugar")) + vbCrLf
   End Sub
End Module
' This example displays the following output:
'
' PROPERTY                    INTERNATIONAL                       TRADITIONAL
' CompareInfo                 CompareInfo - es-ES                 CompareInfo - es-ES_tradnl
' DisplayName                 Spanish (Spain, International Sort) Spanish (Spain, Traditional Sort)
' EnglishName                 Spanish (Spain)                     Spanish (Spain)
' Name                        es-ES                               es-ES
' NativeName                  español (España)                    español (España)
' Parent                      es                                  es
' TextInfo                    TextInfo - es-ES                    TextInfo - es-ES_tradnl
' TwoLetterISOLanguageName    es                                  es
'
' Comparing "llegar" and "lugar"
'    With ciIntl.CompareInfo.Compare: -1
'    With ciTrad.CompareInfo.Compare: 1
using System;
using System.Globalization;
using System.Windows.Media;

public class Example
{
   public static void Demo(System.Windows.Controls.TextBlock outputBlock)
   {
      outputBlock.FontFamily = new FontFamily("Courier New");

      // Create and initialize an es-ES CultureInfo object with the international sort order.
      CultureInfo ciIntl = new CultureInfo("es-ES");

      // Create and initialize an es-ES CultureInfo object with the traditional sort order.
      CultureInfo ciTrad = new CultureInfo("es-ES_tradnl");

      // Display the properties of each culture.
      outputBlock.Text += String.Format("{0,-28}{1,-35}{2,-35}\n", "PROPERTY", "INTERNATIONAL", "TRADITIONAL");
      outputBlock.Text += String.Format("{0,-28}{1,-35}{2,-35}\n", "CompareInfo", ciIntl.CompareInfo, ciTrad.CompareInfo);
      outputBlock.Text += String.Format("{0,-28}{1,-35}{2,-35}\n", "DisplayName", ciIntl.DisplayName, ciTrad.DisplayName);
      outputBlock.Text += String.Format("{0,-28}{1,-35}{2,-35}\n", "EnglishName", ciIntl.EnglishName, ciTrad.EnglishName);
      outputBlock.Text += String.Format("{0,-28}{1,-35}{2,-35}\n", "Name", ciIntl.Name, ciTrad.Name);
      outputBlock.Text += String.Format("{0,-28}{1,-35}{2,-35}\n", "NativeName", ciIntl.NativeName, ciTrad.NativeName);
      outputBlock.Text += String.Format("{0,-28}{1,-35}{2,-35}\n", "Parent", ciIntl.Parent, ciTrad.Parent);
      outputBlock.Text += String.Format("{0,-28}{1,-35}{2,-35}\n", "TextInfo", ciIntl.TextInfo, ciTrad.TextInfo);
      outputBlock.Text += String.Format("{0,-28}{1,-35}{2,-35}\n", "TwoLetterISOLanguageName", ciIntl.TwoLetterISOLanguageName, ciTrad.TwoLetterISOLanguageName);
      outputBlock.Text += "\n";

      // Compare two strings using ciIntl.
      outputBlock.Text += String.Format("Comparing \"llegar\" and \"lugar\"\n");
      outputBlock.Text += String.Format("   With ciIntl.CompareInfo.Compare: {0}\n", ciIntl.CompareInfo.Compare("llegar", "lugar"));
      outputBlock.Text += String.Format("   With ciTrad.CompareInfo.Compare: {0}\n", ciTrad.CompareInfo.Compare("llegar", "lugar"));
   }
}
// This example displays the following output:
//
// PROPERTY                    INTERNATIONAL                       TRADITIONAL
// CompareInfo                 CompareInfo - es-ES                 CompareInfo - es-ES_tradnl
// DisplayName                 Spanish (Spain, International Sort) Spanish (Spain, Traditional Sort)
// EnglishName                 Spanish (Spain)                     Spanish (Spain)
// Name                        es-ES                               es-ES
// NativeName                  español (España)                    español (España)
// Parent                      es                                  es
// TextInfo                    TextInfo - es-ES                    TextInfo - es-ES_tradnl
// TwoLetterISOLanguageName    es                                  es
//
// Comparing "llegar" and "lugar"
//    With ciIntl.CompareInfo.Compare: -1
//    With ciTrad.CompareInfo.Compare: 1

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.