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