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 ํ•™์Šต.