添加Lesson20

This commit is contained in:
2025-10-24 21:47:11 +08:00
parent 0fa8be7459
commit ed22d4bcbd
12 changed files with 612 additions and 0 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>
+23
View File
@@ -0,0 +1,23 @@
using System.Reflection;
namespace Lesson20_反射练习
{
class Program
{
static void Main(string[] args)
{
Assembly assembly = Assembly.LoadFrom(@"D:\VisualStudio2022\VisualStudio Programe\C#\C#进阶\反射练习库\bin\Debug\反射练习库.dll");
Type[] types = assembly.GetTypes();
Console.WriteLine("______________");
for (int i = 0; i < types.Length; i++)
{
Console.WriteLine(types[i]);
}
Console.WriteLine("______________");
Type player = assembly.GetType("反射练习库.Player");
object obj = Activator.CreateInstance(player);
Console.WriteLine(obj);
}
}
}