我现在是最后一次完成这项工作,我有一些值应该在数组中,如下所示:
Timereports.Breaks[] breakValue = { _nestedDateStartBreak1,
_nestedDateEndBreak1,
_nestedDateStartBreak2,
_nestedDateEndBreak2 };
如果我对这篇文章看起来如何看错了,请纠正我: http://msdn.microsoft.com/en-us/library/vstudio/9b9dty7d.aspx
我收到此错误:
'transPA.MainPage.Timereports' is a 'field' but is used like a 'type'
所以我一直在对象浏览器中找到它:
我能从这里看到的内容中得到什么?如何让我的阵列工作。还是我完全迷失了?
答案 0 :(得分:4)
评论后更新的答案:
TimeReports.Breaks = new[] {
new transPA.ServiceReference.BreakDto {
Started = _nestedDateStartBreak1,
Ended = _nestedDateEndBreak1
},
new transPA.ServiceReference.BreakDto {
Started = _nestedDateStartBreak2,
Ended = _nestedDateEndBreak2
}
};
您可以将其更改为
TimeReports.Breaks = new[] {
new BreakDto {
Started = _nestedDateStartBreak1,
Ended = _nestedDateEndBreak1
},
new BreakDto {
Started = _nestedDateStartBreak2,
Ended = _nestedDateEndBreak2
}
};
如果您在文件的开头添加using
语句。
using transPA.ServiceReference;
或者如果使用会导致冲突,您可以更精确:
using BreakDto = transPA.ServiceReference.BreakDto;
答案 1 :(得分:0)
Timereports.Breaks = new transPA.ServiceReference.BreakDto[] { _nestedDateStartBreak1,
_nestedDateEndBreak1,
_nestedDateStartBreak2,
_nestedDateEndBreak2 };