日本免费高清视频-国产福利视频导航-黄色在线播放国产-天天操天天操天天操天天操|www.shdianci.com

學(xué)無(wú)先后,達(dá)者為師

網(wǎng)站首頁(yè) 編程語(yǔ)言 正文

C#?程序通用結(jié)構(gòu)_C#教程

作者:Microsoft ? 更新時(shí)間: 2022-03-16 編程語(yǔ)言

C# 程序由一個(gè)或多個(gè)文件組成。 每個(gè)文件均包含零個(gè)或多個(gè)命名空間。 一個(gè)命名空間包含類、結(jié)構(gòu)、接口、枚舉、委托等類型或其他命名空間。 以下示例是包含所有這些元素的 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
        {
        }
    }
}


前面的示例使用頂級(jí)語(yǔ)句作為程序的入口點(diǎn)。 C# 9 中添加了此功能。 在 C# 9 之前,入口點(diǎn)是名為 Main 的靜態(tài)方法,

如以下示例所示:

// 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!");
        }
    }
}

原文鏈接:https://docs.microsoft.com/zh-cn/dotnet/csharp/fundamentals/program-structure/

欄目分類
最近更新