小编Yan*_*ide的帖子

C# - 一个接口,两个实现:如何将方法调用从一个实现重定向到另一个实现?

我的界面有两个相同名称的实现,如下所示:

interface IDBCaller
{ 
    IEnumerable<User> RetrieveUserList();
    void Method1();
    void Method2();
}

//First implementation of IDBCaller in project1  
class DBCaller : IDBCaller
{

    public IEnumerable<User> RetrieveUserList()
    {
        return new List<User>();
    }

    public void Method1()
    {
        //doing something
    }

    public void Method2()
    {
        //doing something
    }
}
//Second implementation of IDBCaller in project2 
class DBCaller: IDBCaller
{

    public IEnumerable<User> RetrieveUserList()
    {
        return null; //Currently returns null but the desire state is to call the RetrieveUserList in Implementation1 from project 1
    }
    public …
Run Code Online (Sandbox Code Playgroud)

c# interface

0
推荐指数
1
解决办法
84
查看次数

标签 统计

c# ×1

interface ×1