static void RuntimeGetTypeLateBinding() { object s = "Hello"; PropertyInfo pi = s.GetType().GetProperty("Length"); Console.WriteLine((int)pi.GetValue(s, null)); }
Dynamically call method GetMethod() via reflection and late binding in runtime
static void MethodParametersDemo() { Type type = typeof(string); Type[] paraTypes = { typeof(int) }; MethodInfo mi=type.GetMethod ("Substring",paraTypes); Object[] arguments = { 2 }; object returnValue = mi.Invoke("Meditation", arguments); Console.WriteLine(returnValue); }
标签:via,C#,binding,late,returnValue,runtime,type From: https://www.cnblogs.com/Fred1987/p/18061716