using System;
using System.Collections.Generic;
using System.Text;
namespace 接口
{
interface IUSB
{
void Read();
void Write(string s);
}
}
using System;
using System.Collections.Generic;
using System.Text;
namespace 接口
{
class UDisk : IUSB
{
///
/// 存储内容
///
private string content;
public void Read()
{
Console.WriteLine(content);
}
public void Write(string s)
{
content = s;
}
}
}
using System;
using System.Collections.Generic;
using System.Text;
namespace 接口
{
class HardDisk:IUSB
{
private string content;
public void Read()
{
Console.WriteLine(content);
}
public void Write(string s)
{
content = s;
}
}
}
//程序
using System;
namespace 接口
{
class Program
{
static void Main(string[] args)
{
UDisk u1 = new UDisk();
u1.Write("Wei的U盘");
u1.Read();
HardDisk h = new HardDisk();
h.Write("Wei的硬盘");
h.Read();
}
}
}