日期:2014-05-18 浏览次数:21139 次
abcdefgh abcdefg xbcdefe ... aaabcdefgh
string[] str = new string[]{ "gfdsgaaaa", "fds", "fdsgfsdfds", "fdsagfdserre", "rfvffgfdssss" }; var query = str.Where(w => w.Contains("fds")); var result = from w in query where w.Length == query.Max(m => m.Length) select w; foreach (var s in result) Console.WriteLine(s);
------解决方案--------------------
string[] str = new string[] { "gfdsgaaaa", "fds", "fdsgfsdfds", "fdsagfdserre", "rfvffgfdssss" }; var query = str.Where(w => w.Contains("fds")); var result = query.Where(w => w.Length == query.Max(m => m.Length)); foreach (var s in result) Console.WriteLine(s); /** result print: * fdsagfdserre * rfvffgfdssss * */