I have a dictionary with restaurants and a type of restaurant like this: Dictionary<Restaurant, string>
Where restaurants is my class and for simplicity I use a string for my type of restaurant.
Let's say I have 25 entries in my list, where there can be groups of 3, 4 or 5 restaurants with the same type. Now I want to narrow this down to select 1 random element per type.
I have found this page which explains how to pick random values from a dictionary, but how would I go around picking a random entry per grouping of type?
Let me know if I should elaborate more or if you need additional information!
Edit: example of my code:
Dictionary<Restaurant, string> restaurants = new Dictionary<Restaurant, string>();
randomRestaurants.Add(restaurants.GroupBy(x => x.string).//Randomly pick an entry per grouping and add it to list//
List<Restaurant> randomRestaurants = new List<Restaurant>();
For example: Possible types can be Italian
, Fast food
and Sushi
I would like to apologize for asking another confusing question. I'll pay more attention before I post something.