Given a sequence of words with some repeated, such as this:
var words = "one two three two four five six four seven four eight".Split(' ');
You can find duplicates like this You can group the words like this:
var g1 = words.GroupBy(w => w);
I was trying to rewrite that into Linq Query sytnax, just to see what it looks like (I'm aware that in real code you would just leave it like the line above!).
The Linq I came up with looks far more complicated than it should, I think. How can it be simplified? And is it really the same as the line above?
var g2 = from w in words group w by w into g select g;
(I think I'm having a Sunday Brain-Fade... ;)
[EDIT] My source for this wonderment was from the answers to this question from earlier.