添加C#核心实践

添加必备知识点
This commit is contained in:
2025-09-19 19:41:51 +08:00
parent 9ed64928cc
commit 0a1446e7b3
9 changed files with 197 additions and 0 deletions
@@ -0,0 +1,32 @@
using _多脚本文件.TestFile;
namespace _多脚本文件
{
internal class Program
{
static void Main(string[] args)
{
#region
//1. 脚本文件的扩展名是.cs
//2. 同脚本文件夹下的所有脚本文件都可以互相访问
//3. 脚本文件可以在不同的文件夹下,但需要使用命名空间来区分
//4. 目录下的sln是解决方案文件,csproj是项目文件
//5. 同路径下有个bin文件夹,里面存放编译后的文件,debug是调试版本,release是发布版本,都可以直接运行
Test t = new Test();//同一文件夹下的Test.cs脚本文件中定义了Test类,而且使用了相同的命名空间
#endregion
#region
// 右键点击项目文件夹,选择添加->新建项 或 直接在文件夹中新建一个.cs文件
// 接口 类 结构体 可以每个单独放在一个脚本文件中,可以提高代码的可读性和可维护性
#endregion
#region
// 右键项目文件夹,选择添加->新建文件夹
// 新文件夹种可以添加脚本,但是需要using命名空间来引用
TestFiles tf = new TestFiles();
// 当然也可以直接使用命名空间来引用(删除.文件夹名,命名空间直接相同),而不是使用using 必备知识点_多脚本文件.TestFile;这种冗长的方式
#endregion
}
}
}
@@ -0,0 +1,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace _多脚本文件
{
class Test
{
}
}
@@ -0,0 +1,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace _多脚本文件.TestFile
{
class TestFiles
{
}
}
@@ -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>