Hi all I am having a requirement like selecting multiple values and then to delete. I will have some list ofEMployee IDs along with Dates and PayID values.
I will get all this fields in multiple. Now i would like to add this to dictionary element like for particularEmpID I have to assign Date and PayID as keys.
I thought of writing like this
public struct MyValue
{
public List lst;
public List lst1;
public ListDateTime> lstdt;
}
public class MyDictionary : Dictionaryint, MyValue>
{
public void Add(int key, List lst1, List lst2, ListDateTime> lstDt1)
{
MyValue v1=new MyValue();
v1.lst = lst1;
v1.lst1 = lst2;
v1.lstdt = lstDt1;
this.Add(key, v1);
}
}But I am little bit confused in dealing with this so can any one give me an idea to implement as per my requirement.
This is my requirement if I have EmpID as 1 for this I will have Multiple PayIDs and Dates like 1 and System Date.
Even I will get Mutilple EmpIDs But if exists already in the dictionary as Key element I don't want to add it again.
(using 2.0 framework)
How can I do this?

VulpesRank #55 · 29.2K reputationPosted Sep 9, 2011, 1:56 AM EDT
VulpesRank #55 · 29.2K reputationPosted Sep 9, 2011, 12:48 AM EDT
Dorababu MekaRank #457 · 5.5K reputationPosted Sep 9, 2011, 1:01 AM EDT
arrEmpID.Add(1); arrEmpID.Add(1); arrEmpID.Add(2); arrEmpID.Add(2); arrPay.Add(1); arrPay.Add(1); arrPay.Add(2); arrPay.Add(2); DateTime dt = DateTime.Now; DateTime dt1 = DateTime.Now.AddMinutes(1); DateTime dt2 = DateTime.Now.AddMinutes(1); DateTime dt3 = DateTime.Now.AddMinutes(1); arrPayID.Add(dt); arrPayID.Add(dt1); arrPayID.Add(dt2); arrPayID.Add(dt3); EmpIDs = (int[])arrEmpID.ToArray(typeof(int)); Dates = (DateTime[])arrPayID.ToArray(typeof(DateTime)); PayIDs = (int[])arrPay.ToArray(typeof(int)); for (int i = 0; i EmpIDs.Length; i++) { if (!(d.ContainsKey(EmpIDs[i]))) { List values = new List(); ListDateTime> ldt = new ListDateTime>(); d.Add(EmpIDs[i], values, ldt); } d[EmpIDs[i]].lst.Add(PayIDs[i]); d[EmpIDs[i]].lstdt.Add(Dates[i]); } foreach (int EmpID in d.Keys) { foreach (int pID in d[EmpID]) { sb.Append(pID); } foreach (DateTime dtTimes in d[EmpID]) { sb1.Append(dtTimes.ToString()); } } Label1.Text = sb.ToString(); Label2.Text = sb1.ToString();I have my dictionary as follows
public struct MyValue { public List lst; public ListDateTime> lstdt; } public class MyDictionary : Dictionaryint, MyValue> { public void Add(int key, List lst1, ListDateTime> lstDt1) { MyValue v1 = new MyValue(); v1.lst = lst1; v1.lstdt = lstDt1; this.Add(key, v1); } }Dorababu MekaRank #457 · 5.5K reputationPosted Sep 9, 2011, 1:57 AM EDT
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questionsTop experts