Taking random elements out of a collection using LINQ

2. maart 2013 10:05 by martijn in

An elegant solution is so simple that something seems to be missing. I had that feeling when I found this solution of taking a random subset of a set of items:

 

 
 public static IEnumerable<T> TakeRandom<T>(this IEnumerable<T> list, int count) 
{
var shuffledList = list.OrderBy(l => Guid.NewGuid());
return shuffledList.Take(count);
}



szybka iphone 28-5-2015 03:28:36 United States #
szybka iphone

<p>I can’t determine how do I subscribe for your blog</p>

Francis Pettigrew 28-6-2015 12:25:38 United States #
Francis Pettigrew

Its like you read my mind! You seem to know a lot about this, like you wrote the book in it or something. I think that you could do with a few pics to drive the message home a bit, but instead of that, this is excellent blog. A great read. I'll definitely be back.|

blog hog 11-7-2015 05:14:19 United States #
blog hog

For wordpress there is the wphone which works great for simple themes, how about joomla? any way of updating a joomla website via mobile?.

hindi song 15-7-2015 02:50:45 United States #
hindi song

... mp3 download & youtube downloader - Musica Cloud. XXXXXXXXXXXX XXXnXXXXXXX XXXXXXXX XnXX XXXXXXXX XXXXXXXnXXXXXXXX XXXXXXX.

one of a kind bikinis 29-7-2015 19:03:01 United States #
one of a kind bikinis

A person necessarily lend a hand to make seriously posts I'd state. This is the very first time I frequented your web page and so far? I amazed with the analysis you made to create this particular submit amazing. Wonderful task!

agau bendita trama 6-8-2015 01:16:23 United States #
agau bendita trama

I really appreciate this post. I have been looking everywhere for this! Thank goodness I found it on Bing. You have made my day! Thanks again!