亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

傳遞參數類型時該如何處理

傳遞參數類型時該如何處理

繁華開滿天機 2018-08-16 13:14:28
我想使用一個接口,每個繼承此接口的類的傳入的參數類型不同,此時該如何處理為好啊?     public interface IComm     {        bool IConn(c);     }    public class ComConfig     {        public int p;        public int timeout;     }    public class Com :IComm     {               public bool IConn(ComConfig c)          {            return true;                 }         }    public class LanConfig     {        public string ip;        public int port;     }    public class Lan : IComm     {        public bool IConn(LanConfig c)         {            return true;         }     }之前我是想使用泛型來處理,但是好像也不行,我覺得應該有方法實現吧?請各位大神幫幫忙!
查看完整描述

1 回答

  • 1 回答
  • 0 關注
  • 659 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號