CompareInfo.GetCompareInfo Méthode

Définition

Initialise un nouvel CompareInfo objet.

Surcharges

Nom Description
GetCompareInfo(String, Assembly)

Initialise un nouvel CompareInfo objet associé à la culture spécifiée et qui utilise des méthodes de comparaison de chaînes dans le fichier spécifié Assembly.

GetCompareInfo(Int32, Assembly)

Initialise un nouvel CompareInfo objet associé à la culture spécifiée et qui utilise des méthodes de comparaison de chaînes dans le fichier spécifié Assembly.

GetCompareInfo(Int32)

Initialise un nouvel CompareInfo objet associé à la culture avec l’identificateur spécifié.

GetCompareInfo(String)

Initialise un nouvel CompareInfo objet associé à la culture avec le nom spécifié.

GetCompareInfo(String, Assembly)

Initialise un nouvel CompareInfo objet associé à la culture spécifiée et qui utilise des méthodes de comparaison de chaînes dans le fichier spécifié Assembly.

public:
 static System::Globalization::CompareInfo ^ GetCompareInfo(System::String ^ name, System::Reflection::Assembly ^ assembly);
public static System.Globalization.CompareInfo GetCompareInfo(string name, System.Reflection.Assembly assembly);
static member GetCompareInfo : string * System.Reflection.Assembly -> System.Globalization.CompareInfo
Public Shared Function GetCompareInfo (name As String, assembly As Assembly) As CompareInfo

Paramètres

name
String

Chaîne représentant le nom de la culture.

assembly
Assembly

Qui Assembly contient les méthodes de comparaison de chaînes à utiliser.

Retours

Nouvel CompareInfo objet associé à la culture avec l’identificateur spécifié et à l’aide de méthodes de comparaison de chaînes dans l’actuel Assembly.

Exceptions

name a la valeur null.

-ou-

assembly a la valeur null.

name est un nom de culture non valide.

-ou-

assembly est d’un type non valide.

Remarques

Note

Le comportement de cette méthode est imprévisible. Nous vous recommandons d’utiliser une version de cette méthode qui ne prend pas d’entrée d’assembly.

Le assembly paramètre doit être du même type que Module.Assembly.

Voir aussi

S’applique à

GetCompareInfo(Int32, Assembly)

Initialise un nouvel CompareInfo objet associé à la culture spécifiée et qui utilise des méthodes de comparaison de chaînes dans le fichier spécifié Assembly.

public:
 static System::Globalization::CompareInfo ^ GetCompareInfo(int culture, System::Reflection::Assembly ^ assembly);
public static System.Globalization.CompareInfo GetCompareInfo(int culture, System.Reflection.Assembly assembly);
static member GetCompareInfo : int * System.Reflection.Assembly -> System.Globalization.CompareInfo
Public Shared Function GetCompareInfo (culture As Integer, assembly As Assembly) As CompareInfo

Paramètres

culture
Int32

Entier représentant l’identificateur de culture.

assembly
Assembly

Qui Assembly contient les méthodes de comparaison de chaînes à utiliser.

Retours

Nouvel CompareInfo objet associé à la culture avec l’identificateur spécifié et à l’aide de méthodes de comparaison de chaînes dans l’actuel Assembly.

Exceptions

assembly a la valeur null.

assembly est d’un type non valide.

Remarques

Note

Le comportement de cette méthode est imprévisible. Il est recommandé à votre application d’utiliser une version de cette méthode qui ne prend pas d’entrée d’assembly.

Le assembly paramètre doit être du même type que Module.Assembly.

Voir aussi

S’applique à

GetCompareInfo(Int32)

Initialise un nouvel CompareInfo objet associé à la culture avec l’identificateur spécifié.

public:
 static System::Globalization::CompareInfo ^ GetCompareInfo(int culture);
public static System.Globalization.CompareInfo GetCompareInfo(int culture);
static member GetCompareInfo : int -> System.Globalization.CompareInfo
Public Shared Function GetCompareInfo (culture As Integer) As CompareInfo

Paramètres

culture
Int32

Entier représentant l’identificateur de culture.

Retours

Nouvel CompareInfo objet associé à la culture avec l’identificateur spécifié et à l’aide de méthodes de comparaison de chaînes dans l’actuel Assembly.

Exemples

L’exemple suivant compare les parties de deux chaînes à l’aide des différents CompareInfo objets :

// The following code example compares two strings using the different CompareInfo instances:
//    a CompareInfo instance associated with the "Spanish - Spain" culture with international sort,
//    a CompareInfo instance associated with the "Spanish - Spain" culture with traditional sort, and
//    a CompareInfo instance associated with the InvariantCulture.

using System;
using System.Globalization;

public class SamplesCompareInfo  {

   public static void Main()  {

      // Defines the strings to compare.
      String myStr1 = "calle";
      String myStr2 = "calor";

      // Uses GetCompareInfo to create the CompareInfo that uses the "es-ES" culture with international sort.
      CompareInfo myCompIntl = CompareInfo.GetCompareInfo( "es-ES" );

      // Uses GetCompareInfo to create the CompareInfo that uses the "es-ES" culture with traditional sort.
      CompareInfo myCompTrad = CompareInfo.GetCompareInfo( 0x040A );

      // Uses the CompareInfo property of the InvariantCulture.
      CompareInfo myCompInva = CultureInfo.InvariantCulture.CompareInfo;

      // Compares two strings using myCompIntl.
      Console.WriteLine( "Comparing \"{0}\" and \"{1}\"", myStr1, myStr2 );
      Console.WriteLine( "   With myCompIntl.Compare: {0}", myCompIntl.Compare( myStr1, myStr2 ) );
      Console.WriteLine( "   With myCompTrad.Compare: {0}", myCompTrad.Compare( myStr1, myStr2 ) );
      Console.WriteLine( "   With myCompInva.Compare: {0}", myCompInva.Compare( myStr1, myStr2 ) );
   }
}


/*
This code produces the following output.

Comparing "calle" and "calor"
   With myCompIntl.Compare: -1
   With myCompTrad.Compare: 1
   With myCompInva.Compare: -1

*/
' The following code example compares two strings using the different CompareInfo instances:
'    a CompareInfo instance associated with the "Spanish - Spain" culture with international sort,
'    a CompareInfo instance associated with the "Spanish - Spain" culture with traditional sort, and
'    a CompareInfo instance associated with the InvariantCulture.

Imports System.Globalization

Public Class SamplesCompareInfo

   Public Shared Sub Main()

      ' Defines the strings to compare.
      Dim myStr1 As [String] = "calle"
      Dim myStr2 As [String] = "calor"

      ' Uses GetCompareInfo to create the CompareInfo that uses the "es-ES" culture with international sort.
      Dim myCompIntl As CompareInfo = CompareInfo.GetCompareInfo("es-ES")

      ' Uses GetCompareInfo to create the CompareInfo that uses the "es-ES" culture with traditional sort.
      Dim myCompTrad As CompareInfo = CompareInfo.GetCompareInfo(&H40A)

      ' Uses the CompareInfo property of the InvariantCulture.
      Dim myCompInva As CompareInfo = CultureInfo.InvariantCulture.CompareInfo

      ' Compares two strings using myCompIntl.
      Console.WriteLine("Comparing ""{0}"" and ""{1}""", myStr1, myStr2)
      Console.WriteLine("   With myCompIntl.Compare: {0}", myCompIntl.Compare(myStr1, myStr2))
      Console.WriteLine("   With myCompTrad.Compare: {0}", myCompTrad.Compare(myStr1, myStr2))
      Console.WriteLine("   With myCompInva.Compare: {0}", myCompInva.Compare(myStr1, myStr2))

   End Sub

End Class


'This code produces the following output.
'
'Comparing "calle" and "calor"
'   With myCompIntl.Compare: -1
'   With myCompTrad.Compare: 1
'   With myCompInva.Compare: -1

S’applique à

GetCompareInfo(String)

Initialise un nouvel CompareInfo objet associé à la culture avec le nom spécifié.

public:
 static System::Globalization::CompareInfo ^ GetCompareInfo(System::String ^ name);
public static System.Globalization.CompareInfo GetCompareInfo(string name);
static member GetCompareInfo : string -> System.Globalization.CompareInfo
Public Shared Function GetCompareInfo (name As String) As CompareInfo

Paramètres

name
String

Chaîne représentant le nom de la culture.

Retours

Nouvel CompareInfo objet associé à la culture avec l’identificateur spécifié et à l’aide de méthodes de comparaison de chaînes dans l’actuel Assembly.

Exceptions

name a la valeur null.

name est un nom de culture non valide.

Exemples

L’exemple suivant compare les parties de deux chaînes à l’aide des différents CompareInfo objets :

// The following code example compares two strings using the different CompareInfo instances:
//    a CompareInfo instance associated with the "Spanish - Spain" culture with international sort,
//    a CompareInfo instance associated with the "Spanish - Spain" culture with traditional sort, and
//    a CompareInfo instance associated with the InvariantCulture.

using System;
using System.Globalization;

public class SamplesCompareInfo  {

   public static void Main()  {

      // Defines the strings to compare.
      String myStr1 = "calle";
      String myStr2 = "calor";

      // Uses GetCompareInfo to create the CompareInfo that uses the "es-ES" culture with international sort.
      CompareInfo myCompIntl = CompareInfo.GetCompareInfo( "es-ES" );

      // Uses GetCompareInfo to create the CompareInfo that uses the "es-ES" culture with traditional sort.
      CompareInfo myCompTrad = CompareInfo.GetCompareInfo( 0x040A );

      // Uses the CompareInfo property of the InvariantCulture.
      CompareInfo myCompInva = CultureInfo.InvariantCulture.CompareInfo;

      // Compares two strings using myCompIntl.
      Console.WriteLine( "Comparing \"{0}\" and \"{1}\"", myStr1, myStr2 );
      Console.WriteLine( "   With myCompIntl.Compare: {0}", myCompIntl.Compare( myStr1, myStr2 ) );
      Console.WriteLine( "   With myCompTrad.Compare: {0}", myCompTrad.Compare( myStr1, myStr2 ) );
      Console.WriteLine( "   With myCompInva.Compare: {0}", myCompInva.Compare( myStr1, myStr2 ) );
   }
}


/*
This code produces the following output.

Comparing "calle" and "calor"
   With myCompIntl.Compare: -1
   With myCompTrad.Compare: 1
   With myCompInva.Compare: -1

*/
' The following code example compares two strings using the different CompareInfo instances:
'    a CompareInfo instance associated with the "Spanish - Spain" culture with international sort,
'    a CompareInfo instance associated with the "Spanish - Spain" culture with traditional sort, and
'    a CompareInfo instance associated with the InvariantCulture.

Imports System.Globalization

Public Class SamplesCompareInfo

   Public Shared Sub Main()

      ' Defines the strings to compare.
      Dim myStr1 As [String] = "calle"
      Dim myStr2 As [String] = "calor"

      ' Uses GetCompareInfo to create the CompareInfo that uses the "es-ES" culture with international sort.
      Dim myCompIntl As CompareInfo = CompareInfo.GetCompareInfo("es-ES")

      ' Uses GetCompareInfo to create the CompareInfo that uses the "es-ES" culture with traditional sort.
      Dim myCompTrad As CompareInfo = CompareInfo.GetCompareInfo(&H40A)

      ' Uses the CompareInfo property of the InvariantCulture.
      Dim myCompInva As CompareInfo = CultureInfo.InvariantCulture.CompareInfo

      ' Compares two strings using myCompIntl.
      Console.WriteLine("Comparing ""{0}"" and ""{1}""", myStr1, myStr2)
      Console.WriteLine("   With myCompIntl.Compare: {0}", myCompIntl.Compare(myStr1, myStr2))
      Console.WriteLine("   With myCompTrad.Compare: {0}", myCompTrad.Compare(myStr1, myStr2))
      Console.WriteLine("   With myCompInva.Compare: {0}", myCompInva.Compare(myStr1, myStr2))

   End Sub

End Class


'This code produces the following output.
'
'Comparing "calle" and "calor"
'   With myCompIntl.Compare: -1
'   With myCompTrad.Compare: 1
'   With myCompInva.Compare: -1

S’applique à