網(wǎng)站首頁(yè) 編程語(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/
相關(guān)推薦
- 2022-10-12 Python數(shù)據(jù)分析matplotlib折線圖案例處理_python
- 2022-09-13 Android實(shí)現(xiàn)屏幕旋轉(zhuǎn)四個(gè)方向準(zhǔn)確監(jiān)聽_Android
- 2022-07-15 python中進(jìn)程間通信及設(shè)置狀態(tài)量控制另一個(gè)進(jìn)程_python
- 2022-05-04 C#調(diào)用SQL?Server中有參數(shù)的存儲(chǔ)過(guò)程_C#教程
- 2021-12-06 Gin框架之參數(shù)綁定的實(shí)現(xiàn)_Golang
- 2022-04-24 C語(yǔ)言時(shí)間函數(shù)的ctime()和gmtime()你了解嗎_C 語(yǔ)言
- 2022-04-18 Python?字典(Dictionary)詳細(xì)介紹_python
- 2022-12-13 Python使用Matplotlib繪制三維散點(diǎn)圖詳解流程_python
- 最近更新
-
- window11 系統(tǒng)安裝 yarn
- 超詳細(xì)win安裝深度學(xué)習(xí)環(huán)境2025年最新版(
- Linux 中運(yùn)行的top命令 怎么退出?
- MySQL 中decimal 的用法? 存儲(chǔ)小
- get 、set 、toString 方法的使
- @Resource和 @Autowired注解
- Java基礎(chǔ)操作-- 運(yùn)算符,流程控制 Flo
- 1. Int 和Integer 的區(qū)別,Jav
- spring @retryable不生效的一種
- Spring Security之認(rèn)證信息的處理
- Spring Security之認(rèn)證過(guò)濾器
- Spring Security概述快速入門
- Spring Security之配置體系
- 【SpringBoot】SpringCache
- Spring Security之基于方法配置權(quán)
- redisson分布式鎖中waittime的設(shè)
- maven:解決release錯(cuò)誤:Artif
- restTemplate使用總結(jié)
- Spring Security之安全異常處理
- MybatisPlus優(yōu)雅實(shí)現(xiàn)加密?
- Spring ioc容器與Bean的生命周期。
- 【探索SpringCloud】服務(wù)發(fā)現(xiàn)-Nac
- Spring Security之基于HttpR
- Redis 底層數(shù)據(jù)結(jié)構(gòu)-簡(jiǎn)單動(dòng)態(tài)字符串(SD
- arthas操作spring被代理目標(biāo)對(duì)象命令
- Spring中的單例模式應(yīng)用詳解
- 聊聊消息隊(duì)列,發(fā)送消息的4種方式
- bootspring第三方資源配置管理
- GIT同步修改后的遠(yuǎn)程分支