Repository navigation
KO CSharp Conditions
Codex edited this page Oct 11, 2026
·
2 revisions
Українська · Русский · English · Deutsch · Français · Italiano · Español · 繁體中文 · 日本語 · 한국어
if는 bool을 받아들입니다. 계약에 따라 명시적인 비교를 통해 플레이 팀의 수치 결과를 확인합니다(예: result != 0). 명령 설명이 없으면 0을 오류로 간주하지 마십시오.
이 예제를 Example.cs로 따로 저장하고 이 페이지의 다른 예제와 독립적으로 실행하세요.
Example.cs:
// PROJECT-EXAMPLE
int health = 80;
if (health < 50) System.Console.WriteLine("Low");
else System.Console.WriteLine("Ready");결과:
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");
}switch 연산자는 case, when 및 default를 사용하여 분기를 선택합니다. switch-표현식은 값을 반환합니다. 지점에서는 유형, 속성 및 범위 템플릿을 사용할 수 있습니다.
int distance = 3;
string label = distance switch
{
0 => "here",
<= 2 => "near",
< 10 => "reachable area",
_ => "far"
};
UO.Print(label);공식 문서: 조건 및 스위치 - Microsoft Learn.
ClassicUO — Bad Newbie & C# Scripts IDE