vendredi 7 juillet 2017

How to get array of random A-Z letters?

Let me explain what I mean: I have a database that contains 4 columns, one of which is Letter, so each row has a character from 'A' to 'Z', and these aren't unique, so there are multiple rows with 'A', multiple rows with 'B' etc.

What I want to do is get 26 (a-z) rows with ALL letters, but randomize the rows that have the same letters. So I want 26 rows from A to Z, only one A, one B..., and these letters' rows are random. I hope you guys can understand what I mean. Thanks in advance!

I was thinking something like:

var randomQuestions = questions.Distinct().GroupBy(q => q.Letter).Take(26).ToArray();

But I have no idea really.




Aucun commentaire:

Enregistrer un commentaire