.NET with delegate to implement "String Call Method by Method"

xiaoxiao2021-03-06  38

Take a private void jump1 () to call prototype! Public class test {private delegate void JumpboxdeLegate ();

// ---- Call method -----

Private void Jump1 () {MessageBox.show ("jump1");}

Private void Jump2 () {MessageBox.show ("jump2");} // ---------------------------- Public void invokejump (string MethodName) {// add here method of determining, detecting the presence or absence MethodName Type t = typeof (JumpBoxDelegate); Delegate objDelegate = Delegate.CreateDelegate (t, this, MethodName, true); objDelegate.DynamicInvoke (null); }

转载请注明原文地址:https://www.9cbs.com/read-52486.html

New Post(0)