Click here to Skip to main content
14,301,769 members
Rate this:
Please Sign up or sign in to vote.
See more:
hi,

i have two arraylist i want to adda them at a time to Dictionary type in the C#

example like

Dictionary<string, string> dic = new Dictionary<string, string>();
            dic.Add("abc","xyz");
            dic.Add("def","ijk");



but i need to add values of two arraylist
Posted
Comments
Amir Mahfoozi 4-Feb-12 0:15am
   
Your question is not clear. "abc" is the key and "xyz" is the value or "def" is the value ?
   
Why do you feel you need it? Why this is a problem? This operation looks quite straightforward...
--SA
   
Where are the keys, where are the values? Without knowing that, the question is not correct.
--SA
pradeep manne 14-Feb-12 2:43am
   
hi all,
am storing key values in one arraylist(i.e table columns names)
in another list am storing table datatypes
Rate this:
Please Sign up or sign in to vote.

Solution 2

This MAy Help u.

string[] arr = new string[]
    {
        "One",
        "Two"
    };
    var dict = arr.ToDictionary(item => item, item => true);
    foreach (var pair in dict)
    {
        Console.WriteLine("{0}, {1}",
        pair.Key,
        pair.Value);
    }
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100