If I instantiate my subclass of List<string>
, then I can use Linq's Select
method.
using System.Linq;
namespace LinqProblem
{
class Program
{
static void Main(string[] args)
{
BetterList list = new BetterList();
list.Select(l => l.ToString() == "abc"); // no compile error
}
}
}
But if I try to use Select within the definition of the subclass...
using System.Collections.Generic;
using System.Linq;
namespace LinqProblem
{
class BetterList : List<string>
{
public List<string> Stuff
{
get
{
base.Select(l => l.ToString() == "abc"); // compile error
}
}
}
}
Error:
'
List<string>
' does not contain a definition for 'Select'.
Why is this the case, and is there a work-around?