Synchronization of old projects

Part1
This commit is contained in:
2025-09-30 16:46:01 +08:00
parent 116b65164b
commit 4e1548abe2
167 changed files with 8668 additions and 43 deletions
@@ -0,0 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>
+35
View File
@@ -0,0 +1,35 @@
using System;
namespace Lesson5
{
class program
{
static void Main(string[] args)
{
#region
//常量是指在程序运行过程中不会改变的值,必须初始化
//常量的定义:const 数据类型 常量名 = 值;
//常量名一般使用大写字母,多个单词之间用下划线分隔
const int MAX_VALUE = 100;
const string COMPANY_NAME = "ZJ Company";
Console.WriteLine($"最大值: {MAX_VALUE}, 公司名称: {COMPANY_NAME}");
#endregion
#region
//只读变量在定义时可以赋值,也可以在构造函数中赋值,但不能在其他地方修改
class MyClass
{
public readonly int ReadOnlyValue;
public MyClass(int value)
{
ReadOnlyValue = value;
}
}
MyClass myObject = new MyClass(42);
Console.WriteLine($"只读变量值: {myObject.ReadOnlyValue}");
//关键词 const
//固定写法:
//const 变量类型 变量名 = 值;
#endregion
}
}
}