刚学C#,在编写如下程序的时候发生错误:“ConsoleApplication5.ImyInterface.ShowInfo()”: 接口成员不能有定义,渴望各
using System;using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication5
{
interface ImyInterface
{
string ID
{
get;
set;
}
string Name
{
get;
set;
}
void ShowInfo()
{
Console.WriteLine("编号\t 姓名");
Console.WriteLine(ID + "\t" + Name);
}
}
class Program:ImyInterface
{
string id = "";
string name = "";
public string ID
{
get
{
return id;
}
set
{
id = value;
}
}
public string Name
{
get
{
return id;
}
set
{
id = value;
}
}
public void ShowInfo()
{
Console.WriteLine("编号\t 姓名");
Console.WriteLine(ID + "\t" + Name);
}
static void Main(string[] args)
{
Program program = new Program();
ImyInterface imyinterface = program;
imyinterface.ID = "TM";
imyinterface.Name = "Fuck!";
imyinterface.ShowInfo();
}
}
}