Dictionary keys

Can dateTimes be used as keys in a dictionary? I need to associate key hours to temperatures values and also need to be able to span days. Or would you just calculate a key using (dateTime.dayofyear * 24 + dateTime.hours in today) to associate an hour key in the year?

A DateTime would not work as a key in this situation. Use your calculated value instead.

2 Likes

Also make sure that your calculated value will be unique otherwise you will run the risk of writing over an existing key / value that has the same key by accident.

2 Likes