C # question about gettype class

I have an assembly asdf.dll and it has class Class1.

How can I get type Class1?

string a = "Class1"; //Class1 is the name of class in asdf.dll
string typeString = typeof(Class1).FullName; // here I only have the string Class1 and not Class Class1
AssemblyName assemblyName = AssemblyName.GetAssemblyName("asdf.dll");
Type type = Type.GetType(typeString + ", " + assemblyName);

How can I get the class type from a string containing the class name?

+3
source share
2 answers
Type t = Type.GetType("MyDll.MyClass,Mydll")

where MyDll.MyClass is the Location class of your class / form. Mydll is the name of your DLL. which you want to call.

+7
source

typeof(Class1).FullName - This is the full name.

Try just passing this or using the Type.Name property.

+3
source

Source: https://habr.com/ru/post/1704479/


All Articles