<分区>
如果我实例化 List<string>
的子类, 然后我可以使用 Linq 的 Select
方法。
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
}
}
}
但是如果我尝试在子类的定义中使用 Select...
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
}
}
}
}
错误:
'
List<string>
' does not contain a definition for 'Select'.
为什么会这样,是否有解决方法?