我的事件定义如下:
public interface IClass
{
DateTime EffectiveDate { get; set; }
IChild[] Children { get; set; }
}
public interface IChild
{
string From { get; set; }
string To { get; set; }
decimal ADecimal { get; set; }
}
我正在尝试使用以下语法
bus.send<IClass>(class=>
{
class.EffeciveDate = DateTime.now;
class.Children = //Not sure what to do here
}
如何实例化数组并填充子对象?
答案 0 :(得分:0)
Child
并不需要成为在事件中使用createinstance的接口。
你试过了吗?
public interface IClass
{
DateTime EffectiveDate { get; set; }
Child[] Children { get; set; }
}
public class Child
{
string From { get; set; }
string To { get; set; }
decimal ADecimal { get; set; }
}
然后
Child someArray = Child[] { ... some items ... }
bus.send<IClass>(class=>
{
class.EffeciveDate = DateTime.Now;
class.Children = someArray;
}