469,632 Members | 1,698 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,632 developers. It's quick & easy.

Problem in finding the Dictionary Member Types

I am using 3 types of dictionaries.

Expand|Select|Wrap|Line Numbers
  1.  
  2. 1) Dictionary<string, string > d = new Dictionary<string, string>();
  3. 2) Dictionary<string, List<string>> d = new Dictionary<string, List<string>>();
  4. 3) Dictionary<string, Dictionary<string, string>> d = new Dictionary<string, Dictionary<string, string>>();
Now I am using GetDictionaryType Function where I an sending a dictionary object.

In GetDictionaryType() I want to find out which dictionary object has been send.

I am able to check whether type of object is dictionary using following code:

Expand|Select|Wrap|Line Numbers
  1.  
  2. Dictionary<string, string > d = new Dictionary<string, string>();
  3.       Dictionary<string, List<string>> d = new Dictionary<string, List<string>>();
  4.       Dictionary<string, Dictionary<string, string>> d = new Dictionary<string, Dictionary<string, string>>();
  5.  
  6.       System.Type type = d.GetType();
  7.  
  8.       Type constructed = d.GetType();
  9.       Type generic = type.GetGenericTypeDefinition();
  10.  
  11.       if (generic == typeof(Dictionary<,>))
  12.       {
  13.       }
but I want to find out the type of the members.
Where they are <String, List<string>>
or <string,string>
or <string,Dictionary<string,string>>



Please help me for this.

Thanx in advance
May 7 '09 #1
1 2037
Bassem
344 100+
Hello,
I just tested it and works fine, here is:
Expand|Select|Wrap|Line Numbers
  1.             Dictionary<string, string> d = new Dictionary<string, string>();
  2.             Dictionary<int, string> i = new Dictionary<int, string>();
  3.  
  4.             if (i is Dictionary<int, string>)
  5.             {
  6.                 MessageBox.Show(true.ToString());
  7.             }
Modify it to get your problem solved.
May 11 '09 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

12 posts views Thread by teoryn | last post: by
2 posts views Thread by jg | last post: by
10 posts views Thread by exekutive | last post: by
90 posts views Thread by Christoph Zwerschke | last post: by
4 posts views Thread by Larry Bud | last post: by
6 posts views Thread by Gaijinco | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.