'System.Reflection' Tag

  • Call MethodInfo.Invoke with an out parameter

    August 21, 2009

    Taken from http://www.galcho.com/Blog/P… Here is how to call a method with an out parameter using MethodInfo.Invoke, in this case the out parameter is the last one (int). int parNum = 0; string parText = “99″; object[] methodParms = new object[] { parText, parNum }; MethodInfo methInfo = parNum.GetType().GetMethod(“TryParse”, new Type[] { typeof(string), typeof(int).MakeByRefType() }); methInfo.Invoke(null, [...]

    • Share/Bookmark
  • Generic Method Overloading in C#

    February 17, 2009

    Say you have an outer method: public OuterMethod(object x) { InnerMethod(x); } and an inner method with these overloads public InnerMethod(object x) { //Generic Actions } public InnerMethod(Person x) { //Person Specific Actions } public InnerMethod(Dog x) { // Dog Specific Actions } How do you make it so that when the outer method calls [...]

    • Share/Bookmark
 
Powered by Wordpress and MySQL. Theme by Shlomi Noach, openark.org