public string OnKeyPress() { string value = ""; OnKeyPress oo = new OnKeyPress(this.s, this.header); Type t = oo.GetType(); MethodInfo mi = t.GetMethod(this.reference(0)); try { object o = mi.Invoke(oo, null); value = (string)o; } catch (NullReferenceException) { } return(value); }