添加Lesson16
This commit is contained in:
@@ -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!");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user