CompareInfo.GetCompareInfo Метод
Определение
Инициализирует новый объект CompareInfo.Initializes a new CompareInfo object.
Перегрузки
GetCompareInfo(Int32) |
Инициализирует новый объект CompareInfo, связанный с языком и региональными параметрами с заданным идентификатором.Initializes a new CompareInfo object that is associated with the culture with the specified identifier. |
GetCompareInfo(String) |
Инициализирует новый объект CompareInfo, связанный с языком и региональными параметрами с заданным именем.Initializes a new CompareInfo object that is associated with the culture with the specified name. |
GetCompareInfo(Int32, Assembly) |
Инициализирует новый объект CompareInfo, связанный с указанным языком и региональными параметрами и использующий методы сравнения строк в указанном объекте Assembly.Initializes a new CompareInfo object that is associated with the specified culture and that uses string comparison methods in the specified Assembly. |
GetCompareInfo(String, Assembly) |
Инициализирует новый объект CompareInfo, связанный с указанным языком и региональными параметрами и использующий методы сравнения строк в указанном объекте Assembly.Initializes a new CompareInfo object that is associated with the specified culture and that uses string comparison methods in the specified Assembly. |
GetCompareInfo(Int32)
Инициализирует новый объект CompareInfo, связанный с языком и региональными параметрами с заданным идентификатором.Initializes a new CompareInfo object that is associated with the culture with the specified identifier.
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
Параметры
- culture
- Int32
Целое число, представляющее идентификатор языка и региональных параметров.An integer representing the culture identifier.
Возвращаемое значение
Новый объект CompareInfo, связанный с языком и региональными параметрами с заданным идентификатором и использующий методы сравнения строк в текущем объекте Assembly.A new CompareInfo object associated with the culture with the specified identifier and using string comparison methods in the current Assembly.
Примеры
В следующем примере сравниваются части двух строк с использованием различных CompareInfo объектов:The following example compares portions of two strings using the different CompareInfo objects:
CompareInfo Объект, связанный с культурой "Испанский (Испания)" с международной сортировкойCompareInfo object associated with the Spanish (Spain) culture with international sort
CompareInfo Объект, связанный с языком и региональными параметрами для испанского языка (Испания) с традиционной сортировкойCompareInfo object associated with the Spanish (Spain) culture with traditional sort
CompareInfo , связанный с объектом InvariantCultureCompareInfo object associated with the 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
Применяется к
GetCompareInfo(String)
Инициализирует новый объект CompareInfo, связанный с языком и региональными параметрами с заданным именем.Initializes a new CompareInfo object that is associated with the culture with the specified name.
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
Параметры
- name
- String
Строка, представляющая имя языка и региональных параметров.A string representing the culture name.
Возвращаемое значение
Новый объект CompareInfo, связанный с языком и региональными параметрами с заданным идентификатором и использующий методы сравнения строк в текущем объекте Assembly.A new CompareInfo object associated with the culture with the specified identifier and using string comparison methods in the current Assembly.
Исключения
name
имеет значение null
.name
is null
.
Значение параметра name
не является допустимым именем языка и региональных параметров.name
is an invalid culture name.
Примеры
В следующем примере сравниваются части двух строк с использованием различных CompareInfo объектов:The following example compares portions of two strings using the different CompareInfo objects:
CompareInfo Объект, связанный с культурой "Испанский (Испания)" с международной сортировкойCompareInfo object associated with the Spanish (Spain) culture with international sort
CompareInfo Объект, связанный с языком и региональными параметрами для испанского языка (Испания) с традиционной сортировкойCompareInfo object associated with the Spanish (Spain) culture with traditional sort
CompareInfo , связанный с объектом InvariantCultureCompareInfo object associated with the 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
Применяется к
GetCompareInfo(Int32, Assembly)
Инициализирует новый объект CompareInfo, связанный с указанным языком и региональными параметрами и использующий методы сравнения строк в указанном объекте Assembly.Initializes a new CompareInfo object that is associated with the specified culture and that uses string comparison methods in the specified 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
Параметры
- culture
- Int32
Целое число, представляющее идентификатор языка и региональных параметров.An integer representing the culture identifier.
- assembly
- Assembly
Класс Assembly, содержащий используемые методы сравнения строк.An Assembly that contains the string comparison methods to use.
Возвращаемое значение
Новый объект CompareInfo, связанный с языком и региональными параметрами с заданным идентификатором и использующий методы сравнения строк в текущем объекте Assembly.A new CompareInfo object associated with the culture with the specified identifier and using string comparison methods in the current Assembly.
Исключения
assembly
имеет значение null
.assembly
is null
.
Параметр assembly
относится к недопустимому типу.assembly
is of an invalid type.
Комментарии
Примечание
Поведение этого метода является непредсказуемым.The behavior of this method is unpredictable. Рекомендуется, чтобы приложение использовало версию этого метода, которая не принимает входные данные сборки.It is recommended for your application to use a version of this method that does not take an assembly input.
assembly
Параметр должен иметь тот же тип, что и Module.Assembly .The assembly
parameter must be of the same type as Module.Assembly.
См. также раздел
Применяется к
GetCompareInfo(String, Assembly)
Инициализирует новый объект CompareInfo, связанный с указанным языком и региональными параметрами и использующий методы сравнения строк в указанном объекте Assembly.Initializes a new CompareInfo object that is associated with the specified culture and that uses string comparison methods in the specified 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
Параметры
- name
- String
Строка, представляющая имя языка и региональных параметров.A string representing the culture name.
- assembly
- Assembly
Класс Assembly, содержащий используемые методы сравнения строк.An Assembly that contains the string comparison methods to use.
Возвращаемое значение
Новый объект CompareInfo, связанный с языком и региональными параметрами с заданным идентификатором и использующий методы сравнения строк в текущем объекте Assembly.A new CompareInfo object associated with the culture with the specified identifier and using string comparison methods in the current Assembly.
Исключения
name
имеет значение null
.name
is null
.
- или --or-
assembly
имеет значение null
.assembly
is null
.
Значение параметра name
не является допустимым именем языка и региональных параметров.name
is an invalid culture name.
- или --or-
Параметр assembly
относится к недопустимому типу.assembly
is of an invalid type.
Комментарии
Примечание
Поведение этого метода является непредсказуемым.The behavior of this method is unpredictable. Рекомендуется использовать версию этого метода, которая не принимает входные данные сборки.We recommend that you use a version of this method that does not take an assembly input.
assembly
Параметр должен иметь тот же тип, что и Module.Assembly .The assembly
parameter must be of the same type as Module.Assembly.