你能幫助我瞭解更多的細節,需要對Enumerable.Aggregate功能
words.Aggregate((workingSentence, next) => + next + " " + workingSentence);
從下面的代碼片段
?如果有人解釋我在C#1.1中實現這一點,那將會很棒。
(摘錄自MS) -
string sentence = "the quick brown fox jumps over the lazy dog";
// Split the string into individual words.
string[] words = sentence.Split(' ');
// Prepend each word to the beginning of the
// new sentence to reverse the word order.
string reversed = words.Aggregate((workingSentence, next) =>
next + " " + workingSentence);
Console.WriteLine(reversed);
// This code produces the following output:
//
// dog lazy the over jumps fox brown quick the
感謝和清楚,我會嘗試更多的例子基於此。還要感謝Gabe和Will。 – paragy 2010-11-15 13:51:14