这篇文章主要介绍了C# 程序通用结构,C# 程序由一个或多个文件组成。 每个文件均包含零个或多个命名空间。 一个命名空间包含类、结构、接口、枚举、委托等类型或其他命名空间,具体相关内容请需要的小伙伴参考下面文章的详细内容BR
C# 程序由一个或多个文件组成。 每个文件均包含零个或多个命名空间。 一个命名空间包含类、结构、接口、枚举、委托等类型或其他命名空间。 以下示例是包含所有这些元素的 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
{
}
}
}
前面的示例使用顶级语句作为程序的入口点。 C# 9 中添加了此功能。 在 C# 9 之前,入口点是名为 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# 程序通用结构
![](/xwassets/images/pre.png)
![](/xwassets/images/next.png)
猜你喜欢
- c# 模拟线性回归的示例 2023-03-14
- 如何使用C# 捕获进程输出 2023-03-10
- Unity3D实现渐变颜色效果 2023-01-16
- .NET CORE DI 依赖注入 2023-09-27
- C# 使用Aspose.Cells 导出Excel的步骤及问题记录 2023-05-16
- 在C# 8中如何使用默认接口方法详解 2023-03-29
- Unity Shader实现模糊效果 2023-04-27
- WPF使用DrawingContext实现绘制刻度条 2023-07-04
- user32.dll 函数说明小结 2022-12-26
- Oracle中for循环的使用方法 2023-07-04