Solved

Read back from dictionary collection c#

Posted on 2014-07-20
2
192 Views
Last Modified: 2014-07-20
In the code below, after storing some data into 5 objects, I have stored them in a dictionary object using sting keys.

                RodCriteria criteriaLeft= new RodCriteria("CriteriaLeft",101,2,"2014");
                RodCriteria criteriaRight= new RodCriteria("criteriaRight",105,2,"2014");
                RodCriteria criteriaSide= new RodCriteria("criteriaSide",121,2,"2014");
                RodCriteria criteriaGeneral= new RodCriteria("criteriaGeneral",200,2,"2014");
                RodCriteria criteriaDef= new RodCriteria("criteriaDef",100,1,"2014");

                Dictionary<string, RodCriteria> CriteriaCollection = new Dictionary<string, RodCriteria>();
                CriteriaCollection["criteriaLeft"]=criteriaLeft;
                CriteriaCollection["criteriaRight"]=criteriaRight;
                CriteriaCollection["[b]criteriaSide[/b]"]=[b]criteriaSide[/b];
                CriteriaCollection["criteriaGeneral"]=criteriaGeneral;
                CriteriaCollection["criteriaDef"]=criteriaDef;

Open in new window

Now, starting with the dictionary CriteriaCollection and having a key string such as criteriaSide, I want to read back its date as I had them in:

RodCriteria criteriaSide= new RodCriteria("criteriaSide",121,2,"2014");


This should give me:

"criteriaSide"
121
2
2014

Question: How can I do this?

Thank you.
0
Comment
Question by:Mike Eghtebas
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 29

Accepted Solution

by:
Olaf Doschke earned 500 total points
ID: 40207738
See: http://www.dotnetperls.com/dictionary

To read from the dictionary use the index syntax with the key:
RodCriteria ReadFromDict = CriteriaCollection["criteriaSide"];

Open in new window

Now whatever fields or properties of a RodCreteria Type caontain the values 121,2, and"2014" contain them again

Bye, Olaf.
0
 
LVL 34

Author Comment

by:Mike Eghtebas
ID: 40207751
Thank you very much,

Mike
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
This video Micro Tutorial shows how to password-protect PDF files with free software. Many software products can do this, such as Adobe Acrobat (but not Adobe Reader), Nuance PaperPort, and Nuance Power PDF, but they are not free products. This vide…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question