Click here to Skip to main content
15,902,112 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How to map one dictionary to other for example Dictionary<string,Class> to Dictionary<string,Class.Value> ?
Thanks in advance.
Posted
Updated 5-Jun-11 10:28am
v2
Comments
Sergey Alexandrovich Kryukov 5-Jun-11 16:00pm    
Write more exactly what the property in your class should access. How the dictionaries should be mapped, informally?
--SA

Just as you describe.
Have two Dictionary one that holds <string, Class> and the second that has <string, Class.Value>

Class.Value has some Type, like a string, int etc.
The second Dictionary just has to be defined as <string, int>.
 
Share this answer
 
v2
Comments
apaka 5-Jun-11 14:45pm    
For some clearance, my problem is that I have a class that has Dictionary<string,item> and I want to have a property which would alow me to access Distionary<string,inearvalue> which has same keys but values would be Item.Value..
Kim Togo 6-Jun-11 4:05am    
In your Class, you can have a property that holds another Dictionary.

public class MyClass
{
public string MyKey;
public Dictionary<sting, InnerClass>

public class InnerClass
{
public string MyInnerValue;
}
}


You could simply have a Dictionary<string, Class> and access the Class' values by using the key.
For example:

C#
Dictionary<string, MyClass> dictionary = new Dictionary<string, MyClass>();
MyClass instance = new MyClass();
dictionary.Add("MyString", instance);
dictionary["MyString"].Value = "SomeValue"


So it is possible to directly access the Properties and Methods of your Class from the Dictionary when you specify its key.
 
Share this answer
 
v3

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