I faced this type of code and it seems to me that it can be more cleaner. What do you think of that? Can I use some function to do it better?
var dictionary = new Dictionary<int, int>();
foreach (var n in nums)
{
if (dictionary.ContainsKey(n))
dictionary[n]++;
else
dictionary.Add(n, 1);
}
I tried to use "TryGetValue" method but it didn't help