C#C
C#3y ago
__dil__

❔ Entry API for dictionaries?

Rust has this nifty API called
Entry
which allows one to write code such as:
map.entry(c)
   .and_modify(|count_of_c| { *count_of_c += 1 })
   .or_insert(1);

So, you can modify a value in a hashmap (dictionary) if the key exists, or insert a new entry if the key does not exist.

Is there something similar in C#?
Was this page helpful?