C# 프로그램의 일반적인 구조체

C# 프로그램은 하나 이상의 파일로 구성됩니다. 각 파일은 0개 이상의 네임스페이스가 포함합니다. 네임스페이스는 클래스, 구조체, 인터페이스, 열거형 및 대리자와 같은 형식이나 다른 네임스페이스를 포함합니다. 다음 예제는 이러한 모든 요소를 포함하는 C# 프로그램의 기본 구조입니다.

// A skeleton of a C# program
using System;

// Your program starts here:
Console.WriteLine("Hello world!");

namespace YourNamespace
{
    class YourClass
    {
    }

    struct YourStruct
    {
    }

    interface IYourInterface
    {
    }

    delegate int YourDelegate();

    enum YourEnum
    {
    }

    namespace YourNestedNamespace
    {
        struct YourStruct
        {
        }
    }
}

앞의 예제에서는 프로그램의 진입점에 대해 최상위 문을 사용합니다. 다음 예제와 같이 프로그램의 진입점으로 Main(이)라는 정적 메서드를 만들 수도 있습니다.

// A skeleton of a C# program
using System;
namespace YourNamespace
{
    class YourClass
    {
    }

    struct YourStruct
    {
    }

    interface IYourInterface
    {
    }

    delegate int YourDelegate();

    enum YourEnum
    {
    }

    namespace YourNestedNamespace
    {
        struct YourStruct
        {
        }
    }

    class Program
    {
        static void Main(string[] args)
        {
            //Your program starts here...
            Console.WriteLine("Hello world!");
        }
    }
}

기본 사항 가이드의 형식 섹션에서 이러한 프로그램 요소에 대해 알아봅니다.

C# 언어 사양

자세한 내용은 C# 언어 사양기본 개념을 참조하세요. 언어 사양은 C# 구문 및 사용법에 대 한 신뢰할 수 있는 소스 됩니다.