Skip to content

ES CSharp Operator Comparison

Codex edited this page Oct 11, 2026 · 2 revisions

Українська · Русский · English · Deutsch · Français · Italiano · Español · 繁體中文 · 日本語 · 한국어

Comparación

Manual C# · Guía Práctica

Compara el orden de los valores numéricos y devuelve bool. Se pueden declarar operadores para tipos de usuarios.

Ejemplo sencillo (Example.cs)

Guarde este ejemplo por separado como Example.cs. Ejecútelo independientemente de los demás ejemplos de esta página.

Example.cs:

// PROJECT-EXAMPLE
int count = 3;
System.Console.WriteLine(count > 2);

Resultado:

True

Sintaxis

left < right / left >= right

Ejemplo 1

using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using System.IO;
using System.Runtime.InteropServices;
using System.Runtime.CompilerServices;

public static class Program
{
    public static async Task Main(string[] args)
    {
        int value = 12;
        Console.WriteLine($"{value < 15}:{value > 5}:{value <= 12}:{value >= 12}");
    }
}

Ejemplo 2

using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using System.IO;
using System.Runtime.InteropServices;
using System.Runtime.CompilerServices;

public static class Program
{
    public static async Task Main(string[] args)
    {
        decimal balance = 12.5M, price = 8M;
        Console.WriteLine(balance >= price ? "Enough" : "Missing");
    }
}

Fuente oficial: Microsoft Aprender.

Clone this wiki locally