Repository navigation
ES CSharp Patterns
Codex edited this page Oct 11, 2026
·
2 revisions
Українська · Русский · English · Deutsch · Français · Italiano · Español · 繁體中文 · 日本語 · 한국어
La plantilla verifica simultáneamente el valor y puede recuperar los datos. Hay disponibles plantillas para constantes, tipos, propiedades, posiciones, relaciones, listas y combinaciones lógicas and, or, not. _ denota un valor descartado.
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 value = 15;
System.Console.WriteLine(value is > 10 and < 20);Resultado:
True
object value = "backpack";
if (value is string { Length: > 0 } name)
{
UO.Print(name);
}int[] numbers = [1, 2, 3];
string shape = numbers switch
{
[1, .., 3] => "starts with 1 and ends with 3",
[] => "empty",
_ => "other"
};
UO.Print(shape);Documentación oficial: Coincidencia de patrones - Microsoft Learn.
ClassicUO — Bad Newbie & C# Scripts IDE