CKTIS / C#
System.Collections.Generic.IComparer: referencia práctica
System.Collections.Generic.IComparer: referencia práctica: IComparer<T> define un orden mediante un valor negativo, cero o positivo devuelto por Compare.
Versión: .NET API; verified on .NET 10.0.14
Sintaxis
System.Collections.Generic.IComparer /* select a documented member or constructor */IComparer define un orden mediante un valor negativo, cero o positivo devuelto por Compare.
Úsalo como política explícita de ordenación y como regla para colecciones ordenadas.
La comparación debe ser transitiva y coherente; no se deben esperar exactamente los valores menos uno o uno.
Compare(x,x) debe devolver cero y el orden de los valores null debe decidirse conscientemente.
El programa completo usa realmente System.Collections.Generic.IComparer; su stdout esperado exacto es True.
Ejemplos
using System;
using System.Buffers;
using System.Collections.Concurrent;
using System.Collections.Frozen;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Text;
using System.Text.Json;
using System.Text.Json.Nodes;
using System.Text.Json.Serialization;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Channels;
using System.Threading.Tasks;
using Number = System.Int32;
IComparer<string> comparer = StringComparer.OrdinalIgnoreCase;
Console.WriteLine(comparer.Compare("a", "B") < 0);
Resultado
True
El programa completo usa realmente `System.Collections.Generic.IComparer`; su stdout esperado exacto es `True`.