一,新建接口
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(); } }
时间: 2024-10-12 19:56:57