CompareInfo.Name Property
Microsoft Silverlight will reach end of support after October 2021. Learn more.
Gets the name of the culture used for sorting operations by this CompareInfo object.
Namespace: System.Globalization
Assembly: mscorlib (in mscorlib.dll)
Syntax
'Declaration
<ComVisibleAttribute(False)> _
Public Overridable ReadOnly Property Name As String
[ComVisibleAttribute(false)]
public virtual string Name { get; }
Property Value
Type: System.String
The name of a culture.
Examples
The following example compares three strings using the fr-FR and ja-JP cultures. The Name property is used to display the name of each culture.
Imports System.Text
Imports System.Globalization
Public NotInheritable Class Example
Public Shared Sub Demo(ByVal outputBlock As System.Windows.Controls.TextBlock)
Dim sign() As String = {"<", "=", ">"}
' The code below demonstrates how strings compare
' differently for different cultures.
Dim s1 As String = "Coté"
Dim s2 As String = "coté"
Dim s3 As String = "côte"
' Set sort order of strings for French in France.
Dim ci As CompareInfo = New CultureInfo("fr-FR").CompareInfo
' Display the result using fr-FR Compare of Coté = coté.
outputBlock.Text += String.Format("fr-FR Compare: {0} {2} {1}", _
s1, s2, sign((ci.Compare(s1, s2, CompareOptions.IgnoreCase) + 1)))
' Display the result using fr-FR Compare of coté > côte.
outputBlock.Text += String.Format("fr-FR Compare: {0} {2} {1}", _
s2, s3, sign((ci.Compare(s2, s3, CompareOptions.None) + 1)))
' Set sort order of strings for Japanese as spoken in Japan.
ci = New CultureInfo("ja-JP").CompareInfo
' Display the result using ja-JP Compare of coté < côte.
outputBlock.Text += String.Format("ja-JP Compare: {0} {2} {1}", _
s2, s3, sign((ci.Compare(s2, s3) + 1)))
End Sub
End Class
' This code produces the following output.
'
' fr-FR Compare: Coté = coté
' fr-FR Compare: coté > côte
' ja-JP Compare: coté < côte
using System;
using System.Text;
using System.Globalization;
public sealed class Example
{
public static void Demo(System.Windows.Controls.TextBlock outputBlock)
{
String[] sign = new String[] { "<", "=", ">" };
// The code below demonstrates how strings compare
// differently for different cultures.
String s1 = "Coté", s2 = "coté", s3 = "côte";
// Set sort order of strings for French in France.
CompareInfo ci = new CultureInfo("fr-FR").CompareInfo;
// Display the result using fr-FR Compare of Coté = coté.
outputBlock.Text += String.Format("fr-FR Compare: {0} {2} {1}",
s1, s2, sign[ci.Compare(s1, s2, CompareOptions.IgnoreCase) + 1]);
// Display the result using fr-FR Compare of coté > côte.
outputBlock.Text += String.Format("fr-FR Compare: {0} {2} {1}",
s2, s3, sign[ci.Compare(s2, s3, CompareOptions.None) + 1]);
// Set sort order of strings for Japanese as spoken in Japan.
ci = new CultureInfo("ja-JP").CompareInfo;
// Display the result using ja-JP Compare of coté < côte.
outputBlock.Text += String.Format("ja-JP Compare: {0} {2} {1}",
s2, s3, sign[ci.Compare(s2, s3) + 1]);
}
}
// This code produces the following output.
//
// fr-FR Compare: Coté = coté
// fr-FR Compare: coté > côte
// ja-JP Compare: coté < côte
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.