From 7854f97a297de223fca9e9374e280f9d0a9b7ee1 Mon Sep 17 00:00:00 2001 From: Kister Hakusan <2753888203@qq.com> Date: Mon, 8 Sep 2025 16:04:02 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0Lesson12=E7=9A=84=E7=BB=83?= =?UTF-8?q?=E4=B9=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- C#核心/C#核心.sln | 6 ++++ .../Lesson12_继承-继承的基本概念练习.csproj | 11 ++++++ .../Lesson12_继承-继承的基本概念练习/Program.cs | 34 +++++++++++++++++++ 3 files changed, 51 insertions(+) create mode 100644 C#核心/Lesson12_继承-继承的基本概念练习/Lesson12_继承-继承的基本概念练习.csproj create mode 100644 C#核心/Lesson12_继承-继承的基本概念练习/Program.cs diff --git a/C#核心/C#核心.sln b/C#核心/C#核心.sln index 9093761..af87270 100644 --- a/C#核心/C#核心.sln +++ b/C#核心/C#核心.sln @@ -13,6 +13,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lesson11_封装-内部类 EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lesson13_继承-李氏替换原则", "Lesson13_继承-李氏替换原则\Lesson13_继承-李氏替换原则.csproj", "{06C184C2-C60B-4CFC-B3B8-7A8E0754D725}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lesson12_继承-继承的基本概念练习", "Lesson12_继承-继承的基本概念练习\Lesson12_继承-继承的基本概念练习.csproj", "{B432065F-FFA2-4866-BC75-8AC33869B92F}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -39,6 +41,10 @@ Global {06C184C2-C60B-4CFC-B3B8-7A8E0754D725}.Debug|Any CPU.Build.0 = Debug|Any CPU {06C184C2-C60B-4CFC-B3B8-7A8E0754D725}.Release|Any CPU.ActiveCfg = Release|Any CPU {06C184C2-C60B-4CFC-B3B8-7A8E0754D725}.Release|Any CPU.Build.0 = Release|Any CPU + {B432065F-FFA2-4866-BC75-8AC33869B92F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B432065F-FFA2-4866-BC75-8AC33869B92F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B432065F-FFA2-4866-BC75-8AC33869B92F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B432065F-FFA2-4866-BC75-8AC33869B92F}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/C#核心/Lesson12_继承-继承的基本概念练习/Lesson12_继承-继承的基本概念练习.csproj b/C#核心/Lesson12_继承-继承的基本概念练习/Lesson12_继承-继承的基本概念练习.csproj new file mode 100644 index 0000000..8c374af --- /dev/null +++ b/C#核心/Lesson12_继承-继承的基本概念练习/Lesson12_继承-继承的基本概念练习.csproj @@ -0,0 +1,11 @@ + + + + Exe + net8.0 + Lesson12_继承_继承的基本概念练习 + enable + enable + + + diff --git a/C#核心/Lesson12_继承-继承的基本概念练习/Program.cs b/C#核心/Lesson12_继承-继承的基本概念练习/Program.cs new file mode 100644 index 0000000..d72b5f5 --- /dev/null +++ b/C#核心/Lesson12_继承-继承的基本概念练习/Program.cs @@ -0,0 +1,34 @@ +namespace Lesson12_继承_继承的基本概念练习 +{ + class Human + { + public string name; + public int age; + public void Speak() + { + Console.WriteLine("说话"); + } + } + class Warrior : Human + { + public int atk; + public void Attack() + { + Console.WriteLine("攻击"); + } + } + internal class Program + { + static void Main(string[] args) + { + Console.WriteLine("Hello, World!"); + Warrior w = new Warrior(); + w.name = "HK"; + w.age = 18; + w.Speak(); + w.atk = 5; + w.Attack(); + + } + } +}