using System;
using System.Collections.Generic;
public class Test
{
public static void Main()
{
Dictionary<int, int> data = new Dictionary<int, int>() { { 100, 20 }, { 120, 20 }, { 1293, 30 }};
data.Remove(100);
Console.WriteLine(data.Count);
for (int i = 0; i < data.Count; ++i )
Console.WriteLine(data[i]);
}
}
错误:提示未找到指定key
Remove和for不能共存,尽量使用foreach.