首页 > 其他 > 详细

简单的interface显式和隐式的实现

时间:2016-07-05 11:44:44      阅读:123      评论:0      收藏:0      [点我收藏+]

 

 一,新建接口

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

/// <summary>
/// InterF 的摘要说明
/// </summary>

    public interface Itest
    {
        string show();

        string display();
    }

 二,新建接口实现类

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

/// <summary>
/// test 的摘要说明
/// </summary>
public class test :Itest
{
    public string show()
    {
        return "隐式实现接口";
    }

    string Itest.display()
    {
        return "显式实现接口";
    }
}

 三,调用实现

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Mytest : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        Itest a = new test();
        Label1.Text = a.show();
        Label2.Text = a.display();
    }
}

 

简单的interface显式和隐式的实现

原文:http://www.cnblogs.com/May-day/p/5642805.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!