如何在C#中创建一个将<this>类的字符串属性作为参数传递给它的Lazy属性?

时间:2018-03-04 10:05:55

标签: c# lazy-initialization

有没有办法将Name属性作为参数传递给Lazy BOM Initialization?

public class Item
{
    private Lazy<BOM> _BOM = new Lazy<BOM>(); // How to pass the Name as parameter ???

    public Item(string name)
    {
        this.Name = name;         
    }
    public string Name { get; private set; }
    public BOM BOM { get { return _BOM.Value; } }
}

public class BOM
{
    public BOM (string name)
    {
    }
}

0 个答案:

没有答案