Repository navigation
ES CSharp Conditions
Codex edited this page Oct 11, 2026
·
2 revisions
Українська · Русский · English · Deutsch · Français · Italiano · Español · 繁體中文 · 日本語 · 한국어
if acepta bool. Verificar el resultado numérico del equipo jugador mediante una comparación explícita según su contrato, por ejemplo result != 0; No considere ningún cero como un error sin una descripción del comando.
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 health = 80;
if (health < 50) System.Console.WriteLine("Low");
else System.Console.WriteLine("Ready");Resultado:
Ready
int hp = UO.GetHP();
if (hp > 50)
{
UO.Print("High HP");
}
else if (hp > 0)
{
UO.Print("HP is available");
}
else
{
UO.Print("Check character state");
}El operador switch selecciona la rama con case, when y default. La expresión switch devuelve un valor. Las sucursales pueden usar plantillas de tipo, propiedad y rango.
int distance = 3;
string label = distance switch
{
0 => "here",
<= 2 => "near",
< 10 => "reachable area",
_ => "far"
};
UO.Print(label);Documentación oficial: Condiciones y cambio - Microsoft Learn.
ClassicUO — Bad Newbie & C# Scripts IDE