接口的顯示實現和隱式實現

轉自:http://www.cnblogs.com/JustRun1983/archive/2012/06/30/2571450.htmlhtml

接口的隱式實現,也是咱們經常使用的方法。spa

1 public interface IReview
2 {
3     void GetReviews();
4 }
5 public class ShopReview :IReview
6 {
7     //隱式實現
8     public void GetReviews(){}
9 } 

接口的顯式實現。code

1 public interface IReview
2 {
3     void GetReviews();
4 }
5 public class ShopReview :IReview
6 {
7     //顯式實現
8     void IReview.GetReviews(){}
9 } 

隱示實現接口和類均可以訪問htm

顯示實現只有接口能夠訪問blog

也就是,接口能夠訪問顯示實現和隱式顯示,而類只能夠訪問隱式實現接口

相關文章
相關標籤/搜索