Skip to content

KO CSharp Operator Arithmetic

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
System.Console.WriteLine(7 / 2);
double quotient = 7.0 / 2;
System.Console.WriteLine(quotient.ToString(System.Globalization.CultureInfo.InvariantCulture));

결과:

3
3.5

통사론

left + right / left % right / -value

예시 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 left = 17, right = 5;
        Console.WriteLine($"{left + right}:{left - right}:{left * right}:{left / right}:{left % right}");
    }
}

예시 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)
    {
        double value = 17.0 / 5.0;
        Console.WriteLine($"{+value}:{-value}:{Math.Round(value, 2)}");
    }
}

공식 출처: Microsoft 학습.

Clone this wiki locally