KO CSharp Operator Bitwise - 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
int flags = 1 | 2;
System.Console.WriteLine(flags & 2);
๊ฒฐ๊ณผ:
2
ํต์ฌ๋ก
mask & flag / value << count / value >>> count
์์ 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 flags = 0b0101;
Console.WriteLine($"{flags & 0b0011}:{flags | 0b0010}:{flags ^ 0b0001}:{~flags}");
}
}
์์ 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 value = -8;
Console.WriteLine($"{value << 1}:{value >> 1}:{value >>> 1}");
}
}
๊ณต์ ์ถ์ฒ: Microsoft ํ์ต.