如何在此代码中应用依赖注入?

时间:2017-07-07 13:57:34

标签: c# dependency-injection

public class E 
{
    public string Name { get ; }

    public E (string a) 
    {
        Name = a;
    }
}

public class C 
{
    private E MyE { get ; }

    public C (string s)
    {
        MyE = new E ( s );
    }

    public E MM (string ss)
    { 
        return new E ( ss );
    }
}

1 个答案:

答案 0 :(得分:0)

也许您应该在this问题中进行搜索。这种模式有一些例子和解释。