zoukankan      html  css  js  c++  java
  • 简单的interface显式和隐式的实现

     一,新建接口

    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();
        }
    }
  • 相关阅读:
    iOSIPV6简单测试环境搭建
    SQL存儲過程的調試方法
    Excel的 OleDb 连接串的格式
    RequiredFieldValidator的使用
    GridView導出Excel
    咳嗽對症下藥
    WCF基礎
    WCF配置文件全攻略
    WCF寄宿方式
    WCF綁定
  • 原文地址:https://www.cnblogs.com/May-day/p/5642805.html
Copyright © 2011-2022 走看看