能否用改成lambda表达式的形式?
[解决办法]
本帖最后由 q107770540 于 2013-09-03 17:12:34 编辑
int[] myStage = {4,4,3,3,4,4,3,3};
const int pastDays = 10;
int startDay =0;
int stage?=myStage.Select((x,i)=>new {x,i})
.Aggregate((x,y)=>
{
startDay+=x.x;
return startDay>=pastDays?x:y;
}).i;
Console.WriteLine(stage);
int[] myStage = { 4, 4, 1, 3, 4, 4, 3, 3 };
const int pastDays = 10;
int endDay = 0;
int stage = Array.FindIndex(myStage, o =>
{
int startDay = endDay;
endDay = startDay + o;
return (startDay < pastDays && pastDays <= endDay);
});