KO CSharp Operator Logical - LIHACHTETAN/ClassicUO-Bad-Newbie-CSharp-Scripts-IDE GitHub Wiki
ะฃะบัะฐัะฝััะบะฐ ยท ะ ัััะบะธะน ยท English ยท Deutsch ยท Franรงais ยท Italiano ยท Espaรฑol ยท ็น้ซไธญๆ ยท ๆฅๆฌ่ช ยท ํ๊ตญ์ด
๋ ผ๋ฆฌ ์ฐ์ฐ
ํธ๋๋ถ C# ยท ์ค์ฉ ๊ฐ์ด๋
&& ๋ฐ || ์ฌ๋ฐ๋ฅธ ๋ถ๋ถ์ ๋์น ์ ์์ต๋๋ค. & ๋ฐ | ๋ ๋ค ๊ณ์ฐํด ๋ณด์ธ์. ! ๋ถ์ , ^๋ ๋ ผ๋ฆฌ๊ฐ์ ์ฐจ์ด๋ฅผ ํ์ธํฉ๋๋ค.
๊ฐ๋จํ ์์ (Example.cs)
์ด ์์ ๋ฅผ Example.cs๋ก ๋ฐ๋ก ์ ์ฅํ๊ณ ์ด ํ์ด์ง์ ๋ค๋ฅธ ์์ ์ ๋
๋ฆฝ์ ์ผ๋ก ์คํํ์ธ์.
Example.cs:
// PROJECT-EXAMPLE
bool ready = true;
bool stopped = false;
System.Console.WriteLine(ready && !stopped);
๊ฒฐ๊ณผ:
True
ํต์ฌ๋ก
!condition / left && right / left || right
์์ 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)
{
bool ready = true, blocked = false;
Console.WriteLine($"{!blocked}:{ready && !blocked}:{ready || blocked}:{ready ^ blocked}");
}
}
์์ 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 calls = 0;
bool Check() { calls++; return true; }
bool shortResult = false && Check();
bool fullResult = false & Check();
Console.WriteLine($"{shortResult}:{fullResult}:{calls}");
}
}
๊ณต์ ์ถ์ฒ: Microsoft ํ์ต.