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. help needed for Dictionary concept

help needed for Dictionary concept

Scheduled Pinned Locked Moved C#
csharphelptutorial
2 Posts 2 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.
  • P Offline
    P Offline
    Parvai
    wrote on last edited by
    #1

    hi, i am new in c#,how to add values in below Dictionary private Dictionary> batchTable = new Dictionary>(); parthiban

    A 1 Reply Last reply
    0
    • P Parvai

      hi, i am new in c#,how to add values in below Dictionary private Dictionary> batchTable = new Dictionary>(); parthiban

      A Offline
      A Offline
      Are Jay
      wrote on last edited by
      #2

      I have two different ways:

      // Cleaner less controll over the dictionary
      private Dictionary<> innerTable;
      private Dictionary<>>> outterTable;
      
      public DataAccessLayer()
      {
        innerTable = new Dictionary<>();
        outterTable = new Dictionary<>>>();
      
        innerTable.Add( "stringKey", 12312.012 );
        outterTable.Add( "anotherStringKey", innerTable );
      }
      
      
      
      // Longer but you'll define both dictionaries
      // and how all the methods work.
      public class UsingMyNewCollections
      {
        // default constructor
        public UsingMyNewCollections()
        {
          InnerDictionary inner = new InnerDictionary();
          inner.Add( "StringKey", 1213.0123D );
      
      
          OutterDictionary outter = new OutterDictionary();
          batchTable.Add( "SomeKeyString", outter );
        }
      }
      
      public class OutterDictionary : IDictionary<>
      {
        // private field for the class
        private Dictionary<> m_outterDictionary;
      
        // default constructor
        public OutterDictionary()
        {
          m_outterDictionary = new Dictionary<>();
        }
      
        public void Add( string key, InnerDictionary value )
        {
          // Validation on passed in values
          // ...
      
          // Add your value
          m_outterDictionary.Add( key, value );
        }
      
        #region IDictionary<> Members
        // code
        #endregion
      
        #region ICollection<>>> Members
        // code
        #endregion
      
        #region IEnumerable<>>> Members
        // code
        #endregion
      
        #region IEnumerable Members
        //code
        #endregion
      }
      
      public class InnerDictionary : IDictionary<>
      {
        // private field for the class
        private Dictionary<> m_innerDictionary;
      
        // default constructor
        public InnerDictionary()
        {
          m_innerDictionary = new Dictionary<>();
        }
      
      &n
      
      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