So I have a list of fruit objects in List<Fruit> AllFruits
(contains about 60 or so fruit objects) and I also have an empty list of length 3 to house a selection of three fruits List<Fruit> FruitSelection
.
This is part of a quiz like game, so on each round, the positions of the fruits need to be different (randomised).
In C#, how can I select a random fruit from AllFruits
then place that in a random position in FruitSelection
and then do the same for another two fruits, and ensure that they are not duplicates and placed in at a position not already taken within FruitSelection
?
PS. A Fruit has a unique Name
property.