Skip to content

KO CSharp Keyword args

Codex edited this page Oct 11, 2026 · 2 revisions

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

C#: args

핸드북 C# · 실용 가이드

최상위 프로그램의 암시적 string[] 매개변수입니다. 일반 Main에서 이러한 매개변수 이름은 필수 단어가 아니라 관례입니다.

간단한 예제 (Example.cs)

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

Example.cs:

// PROJECT-EXAMPLE
System.Console.WriteLine(args.Length == 0 ? "No arguments" : args[0]);

결과:

No arguments

통사론

string[] args / top-level args

예시 1: 기본 형태

using System; Console.WriteLine(args.Length > 0 ? args[0] : "No arguments");

예 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)
    {
        for (int i = 0; i < args.Length; i++) Console.WriteLine($"{i}:{args[i]}");
    }
}

공식 출처: Microsoft 학습.

Clone this wiki locally