For example I have a class named Temp then I assigned values to it using an IList<Temp>
.
After populating the IList<Temp>
I created a dictionary and assign an int key to each object.
My question is that how do I remove from IList and dictionary the temp_value with the name b and a with a key value of "2"?
class Temp
{
public string name { get; set; }
public Temp(string n)
{
this.name = n;
}
}
Main
class Program
{
static void Main(string[] args)
{
IList<Temp> temp_value = new List<Temp>();
temp_value.Add(new Temp("a")
{
name = "a",
});
temp_value.Add(new Temp("b")
{
name = "b",
});
temp_value.Add(new Temp("b")
{
name = "b",
});
Dictionary<int, Temp> dic = new Dictionary<int, Temp>();
for (int i = 0; i < temp_value.Count; i++)
{
dic.Add(i, temp_value[i]);
}
}
}