4
Answers

How can I use Dictionary for my requirement?

Ask a question
Dorababu Meka

Dorababu Meka

13y
1.1k
1

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<int> lst;
   
public List<int> lst1;
   
public List<DateTime> lstdt;
}

public class MyDictionary : Dictionary<int, MyValue>
{
   
public void Add(int key, List<int> lst1, List<int> lst2, List<DateTime> 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? 


Answers (4)