次のコードでこれを実行しようとしていますが、多くのエラーが発生します。
public abstract class BaseGridViewModel
{
protected BaseGridViewModel()
{
Events = new List<ViewEvent>();
Watch = Stopwatch.StartNew();
}
public SelectList Statuses { get; set; }
public IList<ViewEvent> Events { get; set; }
public string Topics { get; set; }
public SelectList Types { get; set; }
public string View { get; set; }
public Stopwatch Watch { get; set; }
public void Event(string description) {
if (Watch.IsRunning) {
Events.Add(new ViewEvent(description, Watch.ElapsedMilliseconds));
} else {
throw new Exception("Watch not running");
}
}
public long Elapsed {
get {
return Events.Sum(event => event.Elapsed)
}
}
public class ViewEvent {
public long Elapsed { get; private set; }
public string Description { get; private set; }
public string Message { get; private set; }
public int Quantity { get; private set; }
public ViewEvent(string description, long elapsedTime, int quantity = 0, string message = "") {
this.Description = description;
this.Elapsed = elapsedTime;
this.Quantity = quantity;
this.Message = message;
}
}
9 つのエラーはすべて、「return Events.Sum(event => event.Elapsed)」という行に関するものです。
これの構文に何か問題がありますか?