CompareInfo.GetCompareInfo Método
Definición
Importante
Parte de la información hace referencia a la versión preliminar del producto, que puede haberse modificado sustancialmente antes de lanzar la versión definitiva. Microsoft no otorga ninguna garantía, explícita o implícita, con respecto a la información proporcionada aquí.
Inicializa un nuevo objeto CompareInfo.
Sobrecargas
GetCompareInfo(Int32) |
Inicializa un nuevo objeto CompareInfo que está asociado a la referencia cultural con el identificador especificado. |
GetCompareInfo(String) |
Inicializa un nuevo objeto CompareInfo que está asociado a la referencia cultural con el nombre especificado. |
GetCompareInfo(Int32, Assembly) |
Inicializa un nuevo objeto CompareInfo que está asociado a la referencia cultural especificada y que usa los métodos de comparación de cadenas del Assembly especificado. |
GetCompareInfo(String, Assembly) |
Inicializa un nuevo objeto CompareInfo que está asociado a la referencia cultural especificada y que usa los métodos de comparación de cadenas del Assembly especificado. |
GetCompareInfo(Int32)
- Source:
- CompareInfo.cs
- Source:
- CompareInfo.cs
- Source:
- CompareInfo.cs
Inicializa un nuevo objeto CompareInfo que está asociado a la referencia cultural con el identificador especificado.
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
Parámetros
- culture
- Int32
Entero que representa el identificador de referencia cultural.
Devoluciones
Nuevo objeto CompareInfo asociado a la referencia cultural con el identificador especificado y que usa los métodos de comparación de cadenas del Assembly actual.
Ejemplos
En el ejemplo siguiente se comparan partes de dos cadenas mediante los distintos CompareInfo objetos:
CompareInfo objeto asociado a la referencia cultural española (España) con ordenación internacional
CompareInfo objeto asociado a la referencia cultural española (España) con ordenación tradicional
CompareInfo objeto asociado al objeto 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
Se aplica a
GetCompareInfo(String)
- Source:
- CompareInfo.cs
- Source:
- CompareInfo.cs
- Source:
- CompareInfo.cs
Inicializa un nuevo objeto CompareInfo que está asociado a la referencia cultural con el nombre especificado.
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
Parámetros
- name
- String
Cadena que representa el nombre de la referencia cultural.
Devoluciones
Nuevo objeto CompareInfo asociado a la referencia cultural con el identificador especificado y que usa los métodos de comparación de cadenas del Assembly actual.
Excepciones
name
es null
.
name
es un nombre de referencia cultural no válido.
Ejemplos
En el ejemplo siguiente se comparan partes de dos cadenas mediante los distintos CompareInfo objetos:
CompareInfo objeto asociado a la referencia cultural española (España) con ordenación internacional
CompareInfo objeto asociado a la referencia cultural española (España) con ordenación tradicional
CompareInfo objeto asociado al objeto 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
Se aplica a
GetCompareInfo(Int32, Assembly)
- Source:
- CompareInfo.cs
- Source:
- CompareInfo.cs
- Source:
- CompareInfo.cs
Inicializa un nuevo objeto CompareInfo que está asociado a la referencia cultural especificada y que usa los métodos de comparación de cadenas del Assembly especificado.
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
Parámetros
- culture
- Int32
Entero que representa el identificador de referencia cultural.
- assembly
- Assembly
Assembly que contiene los métodos de comparación de cadenas que se van a utilizar.
Devoluciones
Nuevo objeto CompareInfo asociado a la referencia cultural con el identificador especificado y que usa los métodos de comparación de cadenas del Assembly actual.
Excepciones
assembly
es null
.
assembly
es de un tipo no válido.
Comentarios
Nota
El comportamiento de este método es imprevisible. Se recomienda que la aplicación use una versión de este método que no tome una entrada de ensamblado.
El assembly
parámetro debe ser del mismo tipo que Module.Assembly.
Consulte también
Se aplica a
GetCompareInfo(String, Assembly)
- Source:
- CompareInfo.cs
- Source:
- CompareInfo.cs
- Source:
- CompareInfo.cs
Inicializa un nuevo objeto CompareInfo que está asociado a la referencia cultural especificada y que usa los métodos de comparación de cadenas del Assembly especificado.
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
Parámetros
- name
- String
Cadena que representa el nombre de la referencia cultural.
- assembly
- Assembly
Assembly que contiene los métodos de comparación de cadenas que se van a utilizar.
Devoluciones
Nuevo objeto CompareInfo asociado a la referencia cultural con el identificador especificado y que usa los métodos de comparación de cadenas del Assembly actual.
Excepciones
name
es un nombre de referencia cultural no válido.
O bien
assembly
es de un tipo no válido.
Comentarios
Nota
El comportamiento de este método es imprevisible. Se recomienda usar una versión de este método que no tome una entrada de ensamblado.
El assembly
parámetro debe ser del mismo tipo que Module.Assembly.