NameObjectCollectionBase Demo : NameObjectCollectionBase « Collections Data Structure « C# / C Sharp

Home
C# / C Sharp
1.2D Graphics
2.Class Interface
3.Collections Data Structure
4.Components
5.Data Types
6.Database ADO.net
7.Date Time
8.Design Patterns
9.Development Class
10.Event
11.File Stream
12.Generics
13.GUI Windows Form
14.Internationalization I18N
15.Language Basics
16.LINQ
17.Network
18.Office
19.Reflection
20.Regular Expressions
21.Security
22.Services Event
23.Thread
24.Web Services
25.Windows
26.Windows Presentation Foundation
27.XML
28.XML LINQ
C# Book
C# / C Sharp by API
C# / CSharp Tutorial
C# / CSharp Open Source
C# / C Sharp » Collections Data Structure » NameObjectCollectionBaseScreenshots 
NameObjectCollectionBase Demo
  

using System;
using System.Collections;
using System.Collections.Specialized;

public class MyCollection : NameObjectCollectionBase
{
   public MyCollection()  {
   }
   public MyCollectionIDictionary d, Boolean bReadOnly )  {
      foreach DictionaryEntry de in d )  {
         this.BaseAdd( (Stringde.Key, de.Value );
      }
      this.IsReadOnly = bReadOnly;
   }
   public DictionaryEntry thisint index ]  {
      get  {
          return new DictionaryEntry
              this.BaseGetKey(index)this.BaseGet(index) ) );
      }
   }
   public Object thisString key ]  {
      get  {
         returnthis.BaseGetkey ) );
      }
      set  {
         this.BaseSetkey, value );
      }
   }
   public String[] AllKeys  {
      get  {
         returnthis.BaseGetAllKeys() );
      }
   }
   public Array AllValues  {
      get  {
         returnthis.BaseGetAllValues() );
      }
   }
   public String[] AllStringValues  {
      get  {
         return( (String[]) this.BaseGetAllValuestypeofstring ) ));
      }
   }
   public Boolean HasKeys  {
      get  {
         returnthis.BaseHasKeys() );
      }
   }
   public void AddString key, Object value )  {
      this.BaseAddkey, value );
   }
   public void RemoveString key )  {
      this.BaseRemovekey );
   }
   public void Removeint index )  {
      this.BaseRemoveAtindex );
   }
   public void Clear()  {
      this.BaseClear();
   }

}

public class SamplesNameObjectCollectionBase  {
   public static void Main()  {
      IDictionary d = new ListDictionary();
      d.Add"red""apple" );
      MyCollection myROCol = new MyCollectiond, true );

      myROCol.Add"blue""sky" );

      PrintKeysAndValuesmyROCol );

      MyCollection myRWCol = new MyCollection();


   }
   public static void PrintKeysAndValuesMyCollection myCol )  {
      for int i = 0; i < myCol.Count; i++ )  {
         Console.WriteLine"[{0}] : {1}, {2}", i, myCol[i].Key, myCol[i].Value );
      }
   }
}

   
    
  
Related examples in the same category
1.NameObjectCollectionBase is the base class for a collection of associated String keys and Object values
2.Adds an entry with the specified key and value into NameObjectCollectionBase
3.Removes all entries from NameObjectCollectionBase
4.Gets the value of the entry at the specified index of NameObjectCollectionBase
5.Returns a String array that contains all the keys in NameObjectCollectionBase
6.Whether NameObjectCollectionBase contains entries whose keys are not null.
7.Removes the entries with the specified key from NameObjectCollectionBase
8.Sets the value of the entry at the specified index of NameObjectCollectionBase
9.Whether NameObjectCollectionBase is read-only.
10.Represents a collection of associated String keys and String values
java2s.com  |  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.