Reflection method call

Type type = Assembly.Load ( "ModuleName") GetType ( "AssemblyName");. // Get assembly instance System.Type object with the specified name

MethodInfo method = type.GetMethod ( "FunctionName", new type [] {typeof (object)}); // search method specified public parameter and which match the type of the designated parameter

object obj = Activator.CreateInstance (type); // with the specified type of default constructor to create an instance of the type

object[] parameters=new object[]{"value"}; //传参

string result = (string) method.Invoke (obj, parameters); // call to the specified parameters represented by the current method or instance constructor

Guess you like

Origin www.cnblogs.com/Csharp-Soul/p/11445545.html