Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Working with dictionary

Working with dictionary

Scheduled Pinned Locked Moved C#
databasequestion
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    SRKSHOME
    wrote on last edited by
    #1

    Hi, I have to return corresponding country currency from a function. I have a disctionary like Dictionary> that will contain like: Dictionary> str = new Dictionary>(); List currency= GetCurrency();//Will return all currency stored in database. str.Add("Currency",currency); Now currency list contains only currency. I would like to add corresponding country also. I know that I can create datatable,change the dictionary value to DataTable/DataSet type and return.. Datatable is heavy object...So is there any other approach to achieve this? Many thanks.

    L 1 Reply Last reply
    0
    • S SRKSHOME

      Hi, I have to return corresponding country currency from a function. I have a disctionary like Dictionary> that will contain like: Dictionary> str = new Dictionary>(); List currency= GetCurrency();//Will return all currency stored in database. str.Add("Currency",currency); Now currency list contains only currency. I would like to add corresponding country also. I know that I can create datatable,change the dictionary value to DataTable/DataSet type and return.. Datatable is heavy object...So is there any other approach to achieve this? Many thanks.

      L Offline
      L Offline
      Luc Pattyn
      wrote on last edited by
      #2

      Hi, 1. you should use PRE tags to show code snippets, and HTML-escape all < and > and & signs to make them show properly. 2. this would be pretty close to what you want:

      Dictionary<string,string>currencies=new Dictionary<string,string>();
      string country="Belgium";
      string currency="Euro";
      currencies[country]=currency;

      :) EDIT recased some /EDIT

      Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum

      Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.

      modified on Tuesday, February 22, 2011 12:48 PM

      E 1 Reply Last reply
      0
      • L Luc Pattyn

        Hi, 1. you should use PRE tags to show code snippets, and HTML-escape all < and > and & signs to make them show properly. 2. this would be pretty close to what you want:

        Dictionary<string,string>currencies=new Dictionary<string,string>();
        string country="Belgium";
        string currency="Euro";
        currencies[country]=currency;

        :) EDIT recased some /EDIT

        Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum

        Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.

        modified on Tuesday, February 22, 2011 12:48 PM

        E Offline
        E Offline
        Ennis Ray Lynch Jr
        wrote on last edited by
        #3

        your really going to post code that mixes case of local variables to help answer a question?

        Need custom software developed? I do custom programming based primarily on MS tools with an emphasis on C# development and consulting. I also do Android Programming as I find it a refreshing break from the MS. "And they, since they Were not the one dead, turned to their affairs" -- Robert Frost

        L 1 Reply Last reply
        0
        • E Ennis Ray Lynch Jr

          your really going to post code that mixes case of local variables to help answer a question?

          Need custom software developed? I do custom programming based primarily on MS tools with an emphasis on C# development and consulting. I also do Android Programming as I find it a refreshing break from the MS. "And they, since they Were not the one dead, turned to their affairs" -- Robert Frost

          L Offline
          L Offline
          Luc Pattyn
          wrote on last edited by
          #4

          yes it seems I have been on the wrong casing track. All fixed. :thumbsup:

          Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum

          Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups