摘要: 泛型能实现逻辑的重复使用。C#提供5种泛型类、结构、接口、委托和方法。 1.声明泛型类 声明泛型类和普通类差不多 public class mytest<T1,T2>{ public T1 somevar=new T1(); public T2 othervar=new T2(); } 构造类型则在 阅读全文
posted @ 2018-09-21 20:48 国-哥 阅读(438) 评论(0) 推荐(0) 编辑
摘要: 接口是指定一组函数成员而不实现它们的引用类型。所以只能类和结构来实现接口。对不同对象实现相同消息。 示例: Interface Info{ string GetName(); string GetAge();} class CA:Info{ public string name; public st 阅读全文
posted @ 2018-09-21 20:34 国-哥 阅读(410) 评论(0) 推荐(0) 编辑