privatevoiddoWebLogin(StringverifyCode,finalProcActionFuturefuture){LoginModulelogin=getContext().getModule(QQModule.Type.LOGIN);QQAccountaccount=getContext().getAccount();login.webLogin(account.getUsername(),account.getPassword(),account.getUin(),verifyCode,newQQActionListener(){//此處的QQActionListener是個接口,在下面publicvoidonActionEvent(QQActionEventevent){if(event.getType()==QQActionEvent.Type.EVT_OK){doCheckLoginSig((String)event.getTarget(),future);}elseif(event.getType()==QQActionEvent.Type.EVT_ERROR){QQExceptionex=(QQException)(event.getTarget());if(ex.getError()==QQErrorCode.WRONG_CAPTCHA){doGetVerify(ex.getMessage(),future);}else{future.notifyActionEvent(QQActionEvent.Type.EVT_ERROR,(QQException)event.getTarget());}}}});}publicinterfaceQQActionListener{publicvoidonActionEvent(QQActionEventevent);}那么這種語法在C#里怎么【更好的】移植呢?我現(xiàn)在的做法是重寫一個類,繼承QQActionListener,然后在實(shí)例化。但是這種寫法在這個項(xiàng)目中比較多,所以要為了一個方法就要重新寫一個類,實(shí)在是太難看了。請問有什么方法能更好的該寫如上面的那樣的java語法到C#嗎
為什么java可以實(shí)例化接口,這種語法和C#怎么對應(yīng)的?
慕碼人8056858
2019-04-16 17:05:44