Add elements to the table and Use the keys to obtain the values : Hashtable « Data Structure « C# / CSharp Tutorial

C# / CSharp Tutorial
1. Language Basics
2. Data Type
3. Operator
4. Statement
5. String
6. struct
7. Class
8. Operator Overload
9. delegate
10. Attribute
11. Data Structure
12. Assembly
13. Date Time
14. Development
15. File Directory Stream
16. Preprocessing Directives
17. Regular Expression
18. Generic
19. Reflection
20. Thread
21. I18N Internationalization
22. GUI Windows Forms
23. 2D
24. Design Patterns
25. Windows
26. XML
27. ADO.Net
28. Network
29. Directory Services
30. Security
31. unsafe
Java
Java Tutorial
Java Source Code / Java Documentation
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
C# / C Sharp
ASP.Net
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
PHP
Python
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
C# / CSharp Tutorial » Data Structure » Hashtable 
11. 29. 1. Add elements to the table and Use the keys to obtain the values
using System; 
using System.Collections; 
 
class HashtableDemo 
  public static void Main() { 
    Hashtable ht = new Hashtable()
     
    
    ht.Add("a""A")
    ht.Add("b""B")
    ht.Add("c""C")
    ht.Add("e""E")
 
    // Get a collection of the keys. 
    ICollection c = ht.Keys; 
 
    foreach(string str in c
      Console.WriteLine(str + ": " + ht[str])
  
}
a: A
b: B
c: C
e: E
11. 29. Hashtable
11. 29. 1. Add elements to the table and Use the keys to obtain the values
11. 29. 2. Add key-value pair to Hashtable by using the indexer
11. 29. 3. Use foreach statement to loop through all keys in a hashtable
11. 29. 4. Clear all key/value pairs in a Hashtable
11. 29. 5. Mark a Hashtable to be Synchronized
11. 29. 6. Remove key/value pairs from Hashtable
11. 29. 7. Use the ContainsKey() method to check if Hashtable contains a key
11. 29. 8. Use the ContainsValue() method to check if Hashtable contains a value
11. 29. 9. Use the Remove() method to remove FL from Hashtable
11. 29. 10. Copy the keys from Hashtable into an array using the CopyTo() method and then display the array contents
11. 29. 11. Copy the values from Hashtable into an array using the CopyTo() method and then display the array contents
ww_w_.j___av__a_2_s_.co_m_ | Contact Us
Copyright 2003 - 08 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.