What’s the best way to set all values in a C# Dictionary?

That is a reasonable approach, although I would prefer:

foreach (var key in dict.Keys.ToList())
{
    dict[key] = false;
}

The call to ToList() makes this work, since it’s pulling out and (temporarily) saving the list of keys, so the iteration works.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)