本文主要是介绍C# 接口的案例,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
using System;
namespace 接口
{
internal class Program:IMyInterface
{
string id = "";
string name = "";
public string ID { get { return id; } set { id = value; } }
public string Name { get { return name; } set { name = value; } }
static void Main(string[] args)
{
Program program = new Program();
IMyInterface myInterface =program;
program.ID = "TM";
program.Name = "C# 3.5从入门到应用开发";
myInterface.Showinfo();
Console.ReadKey();
}
public void Showinfo()
{
Console.WriteLine("编号\t 姓名");
Console.WriteLine(ID + "\t" + name);
}
}
interface IMyInterface
{
string ID { get; set; }
string Name { get; set; }
void Showinfo();
}
}
这篇关于C# 接口的案例的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!