接口
来源:互联网 发布:厦门欢乐逛公司知乎 编辑:程序博客网 时间:2024/05/01 11:19
接口的实现方式分为显示实现和隐式实现
隐式实现:
public interface IReview
{
void GetReviews();
}
class Program
{
static void Main(string[] args)
{
IReview rv = new Review();
rv.GetReviews(); //显示11
Review rv1 = new Review();
rv1.GetReviews(); //显示11
}
}
public class Review : IReview
{
public void GetReviews()
{
Console.WriteLine("11");
}
}
显式实现:
public interface IReview
{
void GetReviews();
}
class Program
{
static void Main(string[] args)
{
IReview rv = new Review();
rv.GetReviews(); //显示11
Review rv1 = new Review();
rv1.GetReviews(); //异常:没有方法
}
}
public class Review : IReview
{
void IReview.GetReviews()
{
Console.WriteLine("11");
}
}
- 接口
- 接口
- 接口
- 接口
- 接口
- 接口
- 接口
- 接口
- 接口
- 接口
- 接口
- 接口
- 接口
- 接口
- 接口
- 接口
- 接口
- 接口
- j2me 中文字节流 转为中文的字符 手机上运行
- Oracle的程序包
- 《程序员》推荐《正在爆发的互联网革命》
- Java关键字
- 应用架构设计“防火”经验分享
- 接口
- Many people said the high prices
- 在windchill8.0 中如何查詢產品(WTProduct)關聯的所有零件(WTPart)
- word2007无法打开多个文件 鼠标无法使用解决方法
- 星巴克REST案例分析(转载自InfoQ)
- Eclipse debug
- 偷菜的革命 ——献给所有忙于偷菜、乐于偷菜和疲于偷
- hibernate 执行 sql 的奇怪问题
- xp下用户程序空间分配(4):加载主程序