foreach (string item in statsB.Keys)
{
if (statsC.ContainsKey(item))
{
if (statsB[item] == statsC[item])
{
}
else
{
}
}
}
or
foreach (var item in statsB)
{
string key = item.Key;
if (statsC.ContainsKey(key))
{
if (statsB[key] == statsC[key])
{
}
else
{
}
}
}
You should always refer to the documentation when you don't know how to use an object (assuming said object is documented).
Dictionary<TKey,TValue> Class[
^]
KeyValuePair<TKey,TValue> Struct[
^] (the type of
item
in the second solution)
This is also why using
var
for everything doesn't help beginners to clearly understand the code they write.