KO CSharp Keyword else - LIHACHTETAN/ClassicUO-Bad-Newbie-CSharp-Scripts-IDE GitHub Wiki
ะฃะบัะฐัะฝััะบะฐ ยท ะ ัััะบะธะน ยท English ยท Deutsch ยท Franรงais ยท Italiano ยท Espaรฑol ยท ็น้ซไธญๆ ยท ๆฅๆฌ่ช ยท ํ๊ตญ์ด
C#: else
ํธ๋๋ถ C# ยท ์ค์ฉ ๊ฐ์ด๋
์ด์ if์ ์๋ชป๋ ๊ฒฐ๊ณผ์ ๋ํ ๋ถ๊ธฐ๋ฅผ ์ค์ ํฉ๋๋ค. ๊ทธ๋ ์ง ์์ผ๋ฉด ๋ค์ ๊ฒ์ฌ๋ฅผ ์ถ๊ฐํฉ๋๋ค.
๊ฐ๋จํ ์์ (Example.cs)
์ด ์์ ๋ฅผ Example.cs๋ก ๋ฐ๋ก ์ ์ฅํ๊ณ ์ด ํ์ด์ง์ ๋ค๋ฅธ ์์ ์ ๋
๋ฆฝ์ ์ผ๋ก ์คํํ์ธ์.
Example.cs:
// PROJECT-EXAMPLE
int health = 80;
if (health < 50) System.Console.WriteLine("Low");
else System.Console.WriteLine("Ready");
๊ฒฐ๊ณผ:
Ready
ํต์ฌ๋ก
if (condition) { ... } else { ... }
์์ 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 health = 80;
if (health < 50) Console.WriteLine("Heal"); else Console.WriteLine("Ready");
}
}
์ 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)
{
int level = 2;
if (level == 0) Console.WriteLine("None");
else if (level == 1) Console.WriteLine("Low");
else Console.WriteLine("High");
}
}
๊ณต์ ์ถ์ฒ: Microsoft ํ์ต.