提交 86fe1e10 编写于 作者: F feilong

简化节标题

上级 fdf5e396
{
"type": "code_options",
"author": "huanhuilong",
"source": "HelloWorld2.md"
}
\ No newline at end of file
# 第一个完整的C#程序
前一章的习题里我们已经使用C#10.0 的方式,写了一些C#全局代码。在更早的版本里,则需要编写完整的C#代码。例如:
```csharp
using System;
using System.Collections.Generic;
using System.Linq;
namespace Program{
public class Program{
public static void Main(string[] args){
// C# 代码
}
}
}
```
在C# 10.0 里一下代码错误的是?
## 答案
```csharp
WriteLine("Hello, World!");
```
## 选项
### 完整的C#代码
```csharp
using System;
using System.Collections.Generic;
using System.Linq;
namespace Program{
public class Program{
public static void Main(string[] args){
Console.WriteLine("Hello, World!");
}
}
}
```
### 不使用using
```csharp
public class Program{
public static void Main(string[] args){
Console.WriteLine("Hello, World!");
}
}
```
### 全局代码
```csharp
Console.WriteLine("Hello, World!");
```
......@@ -2,5 +2,7 @@
"node_id": "csharp-8f63c0182bed428cb2c75bc1d10a6502",
"keywords": [],
"children": [],
"export": []
"export": [
"HelloWorld2.json"
]
}
\ No newline at end of file
// See https://aka.ms/new-console-template for more information
public class Program{
public static void Main(string[] args){
Console.WriteLine("Hello, World!");
}
}
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册