添加Lesson16

This commit is contained in:
2025-09-11 13:53:18 +08:00
parent 8dcaa99ff4
commit aca44bc248
5 changed files with 172 additions and 0 deletions
@@ -0,0 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<RootNamespace>Lesson16_继承_密封类</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>
@@ -0,0 +1,34 @@
namespace Lesson16_继承_密封类
{
#region
//密封类 是使用 sealed密封关键字修饰的类
//作用:让类无法再被继承
#endregion
#region
class Father
{
}
sealed class Son : Father//之后无法再被继承
{
}
#endregion
#region
//在目前的程序设计中,密封类的主要作用就是不允许最底层子类被继承
//可以保证程序的规范性
//目前对于我们来说 可能用处不大
#endregion
internal class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello, World!");
}
}
}