Compile Error for list.where
c#, generics, list, where-clause
Solution
You need to have
using System.Linq;
at the top of your file.
Problem
I can't figure out why I keep getting this error. Please help!!! 'System.Collections.Generic.List' does not contain a definition for 'Where' and no extension method 'Where' accepting a first argument of type 'System.Collections.Generic.List' could be found (are you missing a using directive or an assembly reference?) ``` using System.Collections.Generic; using System.Collections; public class HistTradePlot : Indicator { private class Traid { public DateTime Date { get; set; } public int Index { get; set; } public int Buy { get; set; } public int Price {get;set;} } List<Traid> traids = new List<Traid>(); if (Bars.FirstBarOfSession) {Bars.Session.GetNextBeginEnd(BarsArray[0], 0, out sessionBegin, out sessionEnd); var sessionTrades = traids.Where(t => t.Date > sessionBegin && t.Date <= sessionEnd); Print("Session Start: " + sessionBegin + " Session End: " + sessionEnd); for (int i=0;i<sessionTrades.Length();i++){ Print(Convert.ToString(sessionTrades[i].Date)); } } ```