Results 1 to 2 of 2

Thread: save a dictionary to app.config

  1. #1

    Thread Starter
    Fanatic Member Crash893's Avatar
    Join Date
    Dec 2005
    Posts
    930

    save a dictionary to app.config

    I'm trying to save a dictonary to app.config for my c# winform

    I see that i can save a stringdictonary under collections.special but i heard thouse are to be avoided if possible becuase there legacy


    is there a way to save a dictonary ( in this case string,string) to the app.config with out haveing to go through a lot of hoops?


    thanks

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,222

    Re: save a dictionary to app.config

    A StringDictionary isn't legacy. It wouldn't be under a System namespace if it was. It was part of the Framework before generics existed so it tends not to be used these days but there's no specific reason not to use it. Just as you store a StringCollection in your settings rather than a List<string>, so too you store a StringDictionary rather than a Dictionary<string, string>. I'm fairly sure that application settings doesn't support generic collections at all, although I haven't tested that theory specifically.
    Last edited by jmcilhinney; May 28th, 2009 at 10:54 PM. Reason: Changed VB syntax to C#
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width