码迷,mamicode.com
首页 > 其他好文 > 详细

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

时间:2016-07-05 11:47:57      阅读:82      评论: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
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!