Fra*_*ser 4 c# linq string linq-to-objects
我有如下单词列表:
List<string> words = new List<string>();
words.Add("abet");
words.Add("abbots"); //<---Return this
words.Add("abrupt");
words.Add("abduct");
words.Add("abnats"); //<--return this.
words.Add("acmatic");
Run Code Online (Sandbox Code Playgroud)
我想返回6个字母的所有单词,以字母"a"开头,并且"t"作为第5个字母,结果应该返回单词"abbots"和"abnats".
var result = from w in words
where w.StartsWith("a") && //where ????
Run Code Online (Sandbox Code Playgroud)
我需要添加什么条款来满足第5个字母的't'要求?
var result = from w in words
where w.Length == 6 && w.StartsWith("a") && w[4] == 't'
select w;
Run Code Online (Sandbox Code Playgroud)