标签:
1 dll 有两个类
class1
1 using System; 2 using System.Collections.Generic; 3 using System.Linq; 4 using System.Text; 5 using System.Threading.Tasks; 6 7 namespace ClassLibrary1 8 { 9 public class Student 10 { 11 private int _ageStudent; 12 private string _nameStudent; 13 public int AgeStudent { get; set; } 14 public int NameStudent { get; set; } 15 public void HelloWorldStudent() { Console.WriteLine("hello world,i am a Student"); } 16 17 } 18 }
class2
1 using System; 2 using System.Collections.Generic; 3 using System.Linq; 4 using System.Text; 5 using System.Threading.Tasks; 6 7 namespace ClassLibrary1 8 { 9 public class Teacher 10 { 11 private int _ageTeacher; 12 private string _nameTeacher; 13 public int AgeTeacher { get; set; } 14 public int NameTeacher { get; set; } 15 public void HelloWorldTeacher(){Console.WriteLine("hello world,i am a teacher");} 16 } 17 }
2 code
1 using System; 2 using System.Collections.Generic; 3 using System.Linq; 4 using System.Reflection; 5 using System.Text; 6 using System.Threading.Tasks; 7 8 namespace ConsoleApplication13 9 { 10 class Program 11 { 12 static void Main(string[] args) 13 { 14 string path = @"D:\用户目录\我的文档\visual studio 2015\Projects\ConsoleApplication13\ClassLibrary1\bin\Debug\ClassLibrary1.dll"; 15 Assembly dllFile = Assembly.LoadFile(path); 16 Type[] classType = dllFile.GetTypes(); 17 18 foreach (var item in classType) 19 { 20 Console.WriteLine(item.Name); 21 } 22 23 Console.ReadKey(); 24 } 25 } 26 }
3 show
C#控制台 assembly与gettypes获取一个dll中的类的名字
标签:
原文地址:http://www.cnblogs.com/jinlingzi/p/5982866.html