C
C#2y ago
populus

Nested KeyValuePair

private KeyValuePair<string, double> priceAndCurrency;

private KeyValuePair<string, KeyValuePair<>> periodAndPriceAndCurrency;
private KeyValuePair<string, double> priceAndCurrency;

private KeyValuePair<string, KeyValuePair<>> periodAndPriceAndCurrency;
I want to create a to-do / shopping list and need to write up price in selected currency and also have a datapoint for things like subscriptions or even due bills. Any other type that would be simpler than what I'm trying to do here? If no, what's wrong with what I'm doing?
4 Replies
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
mtreit
mtreit2y ago
I'm not entirely sure what you are trying to do, but a "nested" KeyValuePair<TKey, TValue> is almost certainly not what you want.
Servator
Servator2y ago
You can use ValueTuple
mtreit
mtreit2y ago
You probably want to define some types (records) to model the entries in your to-do list app to start with. Don't use raw KeyValuePair or Tuple types as they make your intent much less obvious.