Link to home
Start Free TrialLog in
Avatar of adworldmedia
adworldmediaFlag for United States of America

asked on

Create a StringDictionary Class

I want to be able to create a class type with a StringDictionary as one of the members.

        public class Filter
        {
            public string type = "criterion_filter";
            public NameValueCollection patterns;

            public AdultFilter(string Type, NameValueCollection Patterns)
            {
                this.type = Type;
                NameValueCollection patterns = new NameValueCollection();
                patterns.Add(Patterns);
            }
        }

Open in new window


Where I can add multiple patterns into the class, which eventually I'll convert into a JSON object that looks like:

“patterns” : {
     “sex” : [ “s”, “e” ],
      “nin” : [“a”],
      “shoes” : [“f”],
      “run” : [“e”]
}

Open in new window


using the NewtonSoft.Json library...
ASKER CERTIFIED SOLUTION
Avatar of Miguel Oz
Miguel Oz
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
You may use also StringDictionary class:
http://msdn.microsoft.com/en-us/library/system.collections.specialized.stringdictionary.aspx

But I think this is not a problem. What is? From your question I could not understand what are key and what are values, etc. Could you elaborate your question in more details?