C# 程序的通用结构(C# 编程指南)General Structure of a C# Program (C# Programming Guide)

C# 程序可由一个或多个文件组成。C# programs can consist of one or more files. 每个文件均可包含零个或多个命名空间。Each file can contain zero or more namespaces. 一个命名空间可包含类、结构、接口、枚举、委托等类型以及其他命名空间。A namespace can contain types such as classes, structs, interfaces, enumerations, and delegates, in addition to other namespaces. 下面是包含所有这些元素的 C# 程序主干。The following is the skeleton of a C# program that contains all of these elements.

// 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 YourMainClass
    {
        static void Main(string[] args)
        {
            //Your program starts here...
        }
    }
}

更多相关信息:For more information:

C# 语言规范C# Language Specification

有关详细信息,请参阅 C# 语言规范中的基本概念For more information, see Basic concepts in the C# Language Specification. 该语言规范是 C# 语法和用法的权威资料。The language specification is the definitive source for C# syntax and usage.

请参阅See also