Click here to Skip to main content
15,881,803 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
hi,

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

example like

XML
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 ?
Sergey Alexandrovich Kryukov 4-Feb-12 3:05am    
Why do you feel you need it? Why this is a problem? This operation looks quite straightforward...
--SA
Sergey Alexandrovich Kryukov 4-Feb-12 3:07am    
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

 
Share this answer
 
This MAy Help u.

C#
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);
    }
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900