How to iterate over this particular type of Dictionary<int, Result>?
.net, c#
Solution
Dcitionary has a ValueCollection called Values, so the code would be:
foreach (Result r in dict.Values)
{
mynewstring = result.Location;
mynewstringtwo = result.Posted;
}
Problem
I have a bunch of results from the Database that I keep in a `Dictionary<int, Result>()`. The Result class I have is: ``` public int Id { get; set; } public string something { get; set; } public string somethingtwo { get; set; } public string somethingthree { get; set; } public DateTime Posted { get; set; } public string Location { get; set; } public bool somethingfour { get; set; } ``` So, the `Dictionary<int, Result>` has many Results inside and I'd like to iterate over them. How an I do this? I've tried a few ways, but even I knew they wouldn't work. I would like to do something like this: ``` foreach(var result in resultDict) { mynewstring = result.Location; mynewstringtwo = result.Posted; // etc etc. } ```