首页 > 解决方案 > 如何用 GenFu 填充数组

问题描述

在具有 Array 的类上使用 GenFu 不起作用,这是一个最小的可重现示例:

public class Row
{  
    public int Id { get; set; }
    public string[] Cell = new string[5];
} 

public void Test() {
//This line works with a defined property
GenFu.GenFu.Configure<Row>().Fill(r => r.Id, () => { return i++; });

//This line fails (Object Ref not set to an instance)
GenFu.GenFu.Configure<Row>().Fill(r => r.Cell[0], () => { return "Row " + i++.ToString(); });
}

当它们是数组时如何填充单元格,或者这是库的限制?

标签: c#genfu

解决方案


推荐阅读