4
I have a console application, in which there is a list:
List <string> ListaFrases = new List<string>();
This list is built through user inputs in the console. How to display your strings, but in such a way that their position is "shuffled", that is, displayed in random order?
Does this generate draw without repetition? Or can the elements be repeated? For the intention would be to draw without repetition.
– Harison
Without repetition, the
OrderBy
walks through the list and changes the order of each item only once, without generating duplicity.– MurariAlex
How to understand the logic of this excerpt? x => Rnd.Next())
– Harison
rnd.Next()
will provide you with a random number. Thex
is the entry in your string list. TheOrderBy(x => rnd.Next())
is saying that each item (x
) will be ordered by a random numberrnd.Next()
, then, for example, item 1 will receive the number 76 and item 2 the number 31, causing them to be in different orders.– MurariAlex
Right, but I thought that x => Rnd. Next() would be something like "x will be greater or equal to random. I didn’t quite understand the logic
– Harison
Ah, this is a complex starting point. This is called Lamda expressions (lambda Expressions). Check out the explanation in this post https://answall.com/questions/2822/o-que-são-lambda-expressions-e-qual-sacada-usá-las
– MurariAlex