CompareInfo.GetCompareInfo Metoda

Definicja

Inicjuje nowy CompareInfo obiekt.

Przeciążenia

GetCompareInfo(Int32)

Inicjuje nowy CompareInfo obiekt skojarzony z kulturą z określonym identyfikatorem.

GetCompareInfo(String)

Inicjuje nowy CompareInfo obiekt skojarzony z kulturą o określonej nazwie.

GetCompareInfo(Int32, Assembly)

Inicjuje nowy CompareInfo obiekt skojarzony z określoną kulturą i używa metod porównania ciągów w określonym Assemblyobiekcie .

GetCompareInfo(String, Assembly)

Inicjuje nowy CompareInfo obiekt skojarzony z określoną kulturą i używa metod porównania ciągów w określonym Assemblyobiekcie .

GetCompareInfo(Int32)

Źródło:
CompareInfo.cs
Źródło:
CompareInfo.cs
Źródło:
CompareInfo.cs

Inicjuje nowy CompareInfo obiekt skojarzony z kulturą z określonym identyfikatorem.

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

Parametry

culture
Int32

Liczba całkowita reprezentująca identyfikator kultury.

Zwraca

Nowy CompareInfo obiekt skojarzony z kulturą z określonym identyfikatorem i przy użyciu metod porównania ciągów w bieżącym Assemblyobiekcie .

Przykłady

Poniższy przykład porównuje fragmenty dwóch ciągów przy użyciu różnych CompareInfo obiektów:

  • CompareInfo obiekt skojarzony z kulturą hiszpańską (Hiszpania) z rodzajem międzynarodowym

  • CompareInfo obiekt skojarzony z kulturą hiszpańską (Hiszpania) z tradycyjnym sortowaniem

  • CompareInfo obiekt skojarzony z obiektem InvariantCulture

// The following code example compares two strings using the different CompareInfo instances:
//    a CompareInfo instance associated with the S"Spanish - Spain" culture with international sort,
//    a CompareInfo instance associated with the S"Spanish - Spain" culture with traditional sort, and
//    a CompareInfo instance associated with the InvariantCulture.
using namespace System;
using namespace System::Globalization;
int main()
{
   
   // Defines the strings to compare.
   String^ myStr1 = "calle";
   String^ myStr2 = "calor";
   
   // Uses GetCompareInfo to create the CompareInfo that 
   // uses the S"es-ES" culture with international sort.
   CompareInfo^ myCompIntl = CompareInfo::GetCompareInfo( "es-ES" );
   
   // Uses GetCompareInfo to create the CompareInfo that 
   // uses the S"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.

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

Dotyczy

GetCompareInfo(String)

Źródło:
CompareInfo.cs
Źródło:
CompareInfo.cs
Źródło:
CompareInfo.cs

Inicjuje nowy CompareInfo obiekt skojarzony z kulturą o określonej nazwie.

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

Parametry

name
String

Ciąg reprezentujący nazwę kultury.

Zwraca

Nowy CompareInfo obiekt skojarzony z kulturą z określonym identyfikatorem i przy użyciu metod porównania ciągów w bieżącym Assemblyobiekcie .

Wyjątki

name to null.

name jest nieprawidłową nazwą kultury.

Przykłady

Poniższy przykład porównuje fragmenty dwóch ciągów przy użyciu różnych CompareInfo obiektów:

  • CompareInfo obiekt skojarzony z kulturą hiszpańską (Hiszpania) z rodzajem międzynarodowym

  • CompareInfo obiekt skojarzony z kulturą hiszpańską (Hiszpania) z tradycyjnym sortowaniem

  • CompareInfo obiekt skojarzony z obiektem InvariantCulture

// The following code example compares two strings using the different CompareInfo instances:
//    a CompareInfo instance associated with the S"Spanish - Spain" culture with international sort,
//    a CompareInfo instance associated with the S"Spanish - Spain" culture with traditional sort, and
//    a CompareInfo instance associated with the InvariantCulture.
using namespace System;
using namespace System::Globalization;
int main()
{
   
   // Defines the strings to compare.
   String^ myStr1 = "calle";
   String^ myStr2 = "calor";
   
   // Uses GetCompareInfo to create the CompareInfo that 
   // uses the S"es-ES" culture with international sort.
   CompareInfo^ myCompIntl = CompareInfo::GetCompareInfo( "es-ES" );
   
   // Uses GetCompareInfo to create the CompareInfo that 
   // uses the S"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.

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

Dotyczy

GetCompareInfo(Int32, Assembly)

Źródło:
CompareInfo.cs
Źródło:
CompareInfo.cs
Źródło:
CompareInfo.cs

Inicjuje nowy CompareInfo obiekt skojarzony z określoną kulturą i używa metod porównania ciągów w określonym Assemblyobiekcie .

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

Parametry

culture
Int32

Liczba całkowita reprezentująca identyfikator kultury.

assembly
Assembly

Element Assembly zawierający metody porównywania ciągów do użycia.

Zwraca

Nowy CompareInfo obiekt skojarzony z kulturą z określonym identyfikatorem i przy użyciu metod porównania ciągów w bieżącym Assemblyobiekcie .

Wyjątki

assembly to null.

assembly jest nieprawidłowym typem.

Uwagi

Uwaga

Zachowanie tej metody jest nieprzewidywalne. Zaleca się, aby aplikacja korzystała z wersji tej metody, która nie pobiera danych wejściowych zestawu.

Parametr assembly musi mieć taki sam typ jak Module.Assembly.

Zobacz też

Dotyczy

GetCompareInfo(String, Assembly)

Źródło:
CompareInfo.cs
Źródło:
CompareInfo.cs
Źródło:
CompareInfo.cs

Inicjuje nowy CompareInfo obiekt skojarzony z określoną kulturą i używa metod porównania ciągów w określonym Assemblyobiekcie .

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

Parametry

name
String

Ciąg reprezentujący nazwę kultury.

assembly
Assembly

Element Assembly zawierający metody porównywania ciągów do użycia.

Zwraca

Nowy CompareInfo obiekt skojarzony z kulturą z określonym identyfikatorem i przy użyciu metod porównania ciągów w bieżącym Assemblyobiekcie .

Wyjątki

name to null.

-lub-

assembly to null.

name jest nieprawidłową nazwą kultury.

-lub-

assembly jest nieprawidłowym typem.

Uwagi

Uwaga

Zachowanie tej metody jest nieprzewidywalne. Zalecamy użycie wersji tej metody, która nie pobiera danych wejściowych zestawu.

Parametr assembly musi mieć taki sam typ jak Module.Assembly.

Zobacz też

Dotyczy