110,499
社区成员
发帖
与我相关
我的任务
分享
Dictionary<int, string> ports = new Dictionary<int, string>();
ports.Add(1, "port1");
ports.Add(2, "port2");
ports.Add(100, "port100");
foreach (var x in ports.Where(t => t.Key > 10))
{
Console.WriteLine("{0} => {1}", x.Key, x.Value);
}
Console.WriteLine("---");
ports = ports.Where(t => t.Key <= 10).ToDictionary(k=>k.Key,v=>v.Value);
foreach (var x in ports)
{
Console.WriteLine("{0} => {1}", x.Key, x.Value);
}