Last post Sep 30, 2014 01:33 PM by nissan
Member
64 Points
765 Posts
Sep 29, 2014 04:59 PM|nissan|LINK
private IEnumerable<StationEvent> GetStationEvents() { string StationDate = ReportCalculationService.GetStationDate(stationTableName); var SEDateTime = Convert.ToDateTime(StationDate); foreach (var record in data.OrderBy(x => x.DateTimeNum)) { if (record.ST >= 3 && lastRecord.ST < 3) startDateNum = record.DateTimeNum; else if (record.ST < 3 && lastRecord.ST >= 3) { if (startDateNum != null) { var eventStartDate = startDateNum.HasValue ? new DateTimeOffset?(DateTime.FromOADate(startDateNum.Value)) : null, var newEvent = new StationEvent { StationTableName = stationTableName, StartOADate = startDateNum.Value, EndOADate = stationType.ToString() == "BBM" && eventStartDate >= SEDateTime ? record.DateTimeNum : lastRecord.DateTimeNum }; yield return newEvent; } startDateNum = (Double?)null; } }
Hello All,
I have the above code and I am getting this error:
" Cannot use more than one type in a for, using, fixed, or declaration statement"
The error is at this line.
EndOADate = stationType.ToString() == "BMP" && eventStartDate >= SEDateTime ? record.DateTimeNum : lastRecord.DateTimeNum
How should I do this?
All-Star
37441 Points
9076 Posts
Sep 29, 2014 05:56 PM|AidyF|LINK
Try adding parenthesis
EndOADate = (stationType.ToString() == "BBM" && eventStartDate >= SEDateTime) ? record.DateTimeNum : lastRecord.DateTimeNum
Sep 30, 2014 01:33 PM|nissan|LINK
Oops, It was just one typo which I didn't realize..
var eventStartDate = startDateNum.HasValue ? new DateTimeOffset?(DateTime.FromOADate(startDateNum.Value)) : null,The comma at the end was the problem, because of the error I thought something must be really wrong..
Member
64 Points
765 Posts
Cannot use more than one type in a for, using, fixed, or declaration statement
Sep 29, 2014 04:59 PM|nissan|LINK
Hello All,
I have the above code and I am getting this error:
" Cannot use more than one type in a for, using, fixed, or declaration statement"
The error is at this line.
EndOADate = stationType.ToString() == "BMP" && eventStartDate >= SEDateTime ? record.DateTimeNum : lastRecord.DateTimeNum
How should I do this?
All-Star
37441 Points
9076 Posts
Re: Cannot use more than one type in a for, using, fixed, or declaration statement
Sep 29, 2014 05:56 PM|AidyF|LINK
Try adding parenthesis
Member
64 Points
765 Posts
Re: Cannot use more than one type in a for, using, fixed, or declaration statement
Sep 30, 2014 01:33 PM|nissan|LINK
Oops, It was just one typo which I didn't realize..