Как с помощью рифлексии узнать имя класса - C#
Формулировка задачи:
Добрый день! Подскажите как с помощью рифлексии узнать имя класса? в .dll
Решение задачи: «Как с помощью рифлексии узнать имя класса»
textual
Листинг программы
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Reflection;
namespace ConsoleApplication1 {
class Program {
static void Main(string[] args) {
byte[] assembly = File.ReadAllBytes("System.Core.dll");
Assembly asm = null;
try {
asm = Assembly.Load(assembly);
}
catch (Exception ex) {
Console.WriteLine(ex.Message);
return;
}
string[] names = asm.GetTypes().Where(t => t.IsClass).Select(t => t.Name).ToArray();
foreach (string name in names) {
Console.WriteLine(name);
}
Console.ReadLine();
}
}
}