在C#中怎么用泛型集合Dictionary删除有索引的数据
展开全部
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
Dictionary testData = new Dictionary() { { 1, "1" }, { 2, "2" }, { 3, "3" }, {4, "4" }, { 5, "5" }, { 6, "6" } };
testData.Remove(4);
foreach (var item in testData.Keys)
{
Console.WriteLine(testData[item]);
}
Console.ReadKey();
}
}
}
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
Dictionary testData = new Dictionary() { { 1, "1" }, { 2, "2" }, { 3, "3" }, {4, "4" }, { 5, "5" }, { 6, "6" } };
testData.Remove(4);
foreach (var item in testData.Keys)
{
Console.WriteLine(testData[item]);
}
Console.ReadKey();
}
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询