110,546
社区成员
发帖
与我相关
我的任务
分享
/// <summary>
/// 业务A的接口
/// </summary>
public interface IA
{
void SelectA();
void InsertA();
void DeleteA();
void UpdateA();
}
/// <summary>
/// 业务B的接口
/// </summary>
public interface IB
{
void SelectB();
void InsertB();
}
/// <summary>
/// 业务A
/// </summary>
public class A : IA
{
public void SelectA()
{
//添加方法
}
public void InsertA()
{
//添加方法
}
public void DeleteA()
{
//添加方法
}
public void UpdateA()
{
//添加方法
}
}
/// <summary>
/// 业务B
/// </summary>
public class B : IB
{
public void SelectB()
{
//添加方法
}
public void InsertB()
{
//添加方法
}
}
static void Main(string[] args)
{
IA Ia = new A();
Ia.Select();
Ia.Insert();
Ia.Delete();
Ia.Update();
IB Ib = new B();
Ib.Select();
Ib.Insert();
}
/// <summary>
/// 接口
/// </summary>
public interface IT
{
void Select();
void Insert();
void Delete();
void Update();
}
/// <summary>
/// 第一遍实现
/// </summary>
public class ITClass : IT
{
public virtual void Select()
{ }
public virtual void Insert()
{ }
public virtual void Delete()
{ }
public virtual void Update()
{ }
}
/// <summary>
/// 业务A--重写第二遍实现
/// </summary>
public class A : ITClass
{
public override void Select()
{
//添加方法
}
public override void Insert()
{
//添加方法
}
public override void Delete()
{
//添加方法
}
public override void Update()
{
//添加方法
}
}
/// <summary>
/// 业务B--重写第二遍实现
/// </summary>
public class B : ITClass
{
public override void Select()
{
//添加方法
}
public override void Insert()
{
//添加方法
}
}
static void Main(string[] args)
{
IT It = new A();
It.Select();
It.Insert();
It.Delete();
It.Update();
It = new B();
It.Select();
It.Insert();
}
/// <summary>
/// 接口s
/// </summary>
public interface ITS
{
void Select();
}
/// <summary>
/// 接口i
/// </summary>
public interface ITI
{
void Insert();
}
/// <summary>
/// 接口d
/// </summary>
public interface ITD
{
void Delete();
}
/// <summary>
/// 接口u
/// </summary>
public interface ITU
{
void Update();
}
/// <summary>
/// 业务A--
/// </summary>
public class A : ITS,ITI,ITU,ITD
{
public void Select()
{
//添加方法
}
public void Insert()
{
//添加方法
}
public void Delete()
{
//添加方法
}
public void Update()
{
//添加方法
}
}
/// <summary>
/// 业务B--
/// </summary>
public class B : ITS,ITI
{
public void Select()
{
//添加方法
}
public void Insert()
{
//添加方法
}
}
static void Main(string[] args)
{
ITS Its = new A();
Its.Select();
ITI Iti = new A();
Iti.Insert();
ITD Itd = new A();
Itd.Delete();
ITU Itu = new A();
Itu.Update();
ITS ITs = new B();
ITs.Select();
ITI ITi = new B();
Iti.Insert();
}