using System;
namespace Articulos.Cap06
{
public class ComparacionStrings
{
public static void Main()
{
string[] cadenas = new string[] {"Einstein", "einstein", "Newton"};
// Comparación independiente de la cultura:
Array.Sort(cadenas, StringComparer.InvariantCulture);
// Visualización de resultados:
Console.WriteLine ("Comparación independiente de la cultura:");
Array.ForEach(cadenas, cadena => Console.WriteLine (cadena));
Console.WriteLine ();
// Comparación ordinal:
Array.Sort(cadenas, StringComparer.Ordinal);
// Visualización de resultados:
Console.WriteLine ("Comparación ordinal:");
Array.ForEach(cadenas, cadena => Console.WriteLine (cadena));
}
}
}
dXNpbmcgU3lzdGVtOwoKbmFtZXNwYWNlIEFydGljdWxvcy5DYXAwNgp7CiAgICBwdWJsaWMgY2xhc3MgQ29tcGFyYWNpb25TdHJpbmdzCiAgICB7CiAgICAgICAgcHVibGljIHN0YXRpYyB2b2lkIE1haW4oKSAKICAgICAgICB7CiAgICAgICAgICAgIHN0cmluZ1tdIGNhZGVuYXMgPSBuZXcgc3RyaW5nW10geyJFaW5zdGVpbiIsICJlaW5zdGVpbiIsICJOZXd0b24ifTsKICAgICAgICAgICAgCiAgICAgICAgICAgIC8vIENvbXBhcmFjacOzbiBpbmRlcGVuZGllbnRlIGRlIGxhIGN1bHR1cmE6CiAgICAgICAgICAgIEFycmF5LlNvcnQoY2FkZW5hcywgU3RyaW5nQ29tcGFyZXIuSW52YXJpYW50Q3VsdHVyZSk7CiAgICAgICAgICAgIC8vIFZpc3VhbGl6YWNpw7NuIGRlIHJlc3VsdGFkb3M6CiAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lICgiQ29tcGFyYWNpw7NuIGluZGVwZW5kaWVudGUgZGUgbGEgY3VsdHVyYToiKTsKICAgICAgICAgICAgQXJyYXkuRm9yRWFjaChjYWRlbmFzLCBjYWRlbmEgPT4gQ29uc29sZS5Xcml0ZUxpbmUgKGNhZGVuYSkpOwogICAgICAgICAgICAKICAgICAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUgKCk7CiAgIC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