Skip to content

KO CSharp Operator Assignment

Codex edited this page Oct 11, 2026 · 2 revisions

Українська · Русский · English · Deutsch · Français · Italiano · Español · 繁體中文 · 日本語 · 한국어

인가

핸드북 C# · 실용 가이드

변수 또는 쓰기 가능한 멤버에 값을 저장합니다. 복합형은 연산을 적용하고 좌변의 계산을 중복하지 않고 결과를 기록한다.

간단한 예제 (Example.cs)

이 예제를 Example.cs로 따로 저장하고 이 페이지의 다른 예제와 독립적으로 실행하세요.

Example.cs:

// PROJECT-EXAMPLE
int count = 2;
count += 3;
System.Console.WriteLine(count);

결과:

5

통사론

value = expression / value += amount

예시 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 value = 10;
        value += 5; value -= 2; value *= 3; value /= 2; value %= 7;
        Console.WriteLine(value);
    }
}

예시 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 mask = 0b0011;
        mask |= 0b0100; mask &= 0b0111; mask ^= 0b0001;
        mask <<= 2; mask >>= 1; mask >>>= 1;
        Console.WriteLine(mask);
    }
}

공식 출처: Microsoft 학습.

Clone this wiki locally