using System;
using System.Collections.Generic;
using System.Linq;
public class Test
{
public static void Main()
{
var dict = new Dictionary<int, int>()
{
{ 0, 0 },
{ 5, 5 },
{ 7, 7 }
};
Console.WriteLine("Original");
foreach (var kvp in dict)
Console.WriteLine("{0} -> {1}", kvp.Key, kvp.Value);
foreach (var key in dict.Keys.ToList())
dict[key]++;
Console.WriteLine("Increased by 1");
foreach (var kvp in dict)
Console.WriteLine("{0} -> {1}", kvp.Key, kvp.Value);
dict = dict.ToDictionary(kvp => kvp.Key, kvp => kvp.Value + 1);
Console.WriteLine("Increased by 1 again");
foreach (var kvp in dict)
Console.WriteLine("{0} -> {1}", kvp.Key, kvp.Value);
}
}
dXNpbmcgU3lzdGVtOwp1c2luZyBTeXN0ZW0uQ29sbGVjdGlvbnMuR2VuZXJpYzsKdXNpbmcgU3lzdGVtLkxpbnE7CgpwdWJsaWMgY2xhc3MgVGVzdAp7CiAgICBwdWJsaWMgc3RhdGljIHZvaWQgTWFpbigpCiAgICB7CiAgICAgICAgdmFyIGRpY3QgPSBuZXcgRGljdGlvbmFyeTxpbnQsIGludD4oKQogICAgICAgIHsKICAgICAgICAgICAgeyAwLCAwIH0sCiAgICAgICAgICAgIHsgNSwgNSB9LAogICAgICAgICAgICB7IDcsIDcgfQogICAgICAgIH07CiAgICAgICAgCiAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoIk9yaWdpbmFsIik7CiAgICAgICAgZm9yZWFjaCAodmFyIGt2cCBpbiBkaWN0KQogICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZSgiezB9IC0+IHsxfSIsIGt2cC5LZXksIGt2cC5WYWx1ZSk7CgogICAgICAgIGZvcmVhY2ggKHZhciBrZXkgaW4gZGljdC5LZXlzLlRvTGlzdCgpKQogICAgICAgICAgICBkaWN0W2tleV0rKzsKICAgICAgICAgICAgCiAgICAgICAgQ29uc29sZS5Xcml0ZUxpbmUoIkluY3JlYXNlZCBieSAxIik7CiAgICAgICAgZm9yZWFjaCAodmFyIGt2cCBpbiBkaWN0KQogICAgICAgICAgICBDb25zb2xlLldyaXRlTGluZSgiezB9IC0+IHsxfSIsIGt2cC5LZXksIGt2cC5WYWx1ZSk7CiAgICAgICAgICAgIAogICAgICAgIGRpY3QgPSBkaWN0LlRvRGljdGlvbmFyeShrdnAgPT4ga3ZwLktleSwga3ZwID0+IGt2cC5WYWx1ZSArIDEpOwoKICAgICAgICBDb25zb2xlLldyaXRlTGluZSgiSW5jcmVhc2VkIGJ5IDEgYWdhaW4iKTsKICAgICAgICBmb3JlYWNoICh2YXIga3ZwIGluIGRpY3QpCiAgICAgICAgICAgIENvbnNvbGUuV3JpdGVMaW5lKCJ7MH0gLT4gezF9Iiwga3ZwLktleSwga3ZwLlZhbHVlKTsKICAgIH0KfQ==