1
を合理化することができます各単語の使用。 1つのLINQ式を保持することは可能ですが、fromとlet式のstring.Concatセクションをレプリケートする必要はありません。は、私は今、私は2つの文字列を持っていると私はカウントするように連結された文字列を解析...</p> <p>を私はLINQを学んでいると私は次のLINQクエリを効率化することが可能であるかどうかを知りたい、このLINQクエリ
string sentence = "this is the first sentence";
string sentence2 = "this is the second sentence";
var res = from word in string.Concat(sentence, sentence2).Split()
let combinedwords = string.Concat(sentence, sentence2).Split()
select new { TheWord = word, Occurance = combinedwords.Count(x => x.Equals(word)) };
ありがとう、これは私が探していたものです。 –