Set & amp; gt; hash table class Hashtable and SortedList sort list class

Source: Internet
Author: User

Set> hash table class Hashtable

Hashtable is a set of key-value pairs. The hash table is unordered and does not provide a sorting method.

 

Set> hash table class Hashtable> construct a normal hash table

Code Using System;
Using System. Collections. Generic;
Using System. Text;
Using System. Collections;

Namespace ConsoleApplication1
{
Class Program
{
Static void Main (string [] args)
{
// Use all default values to create a hash table instance
Hashtable ht = new Hashtable ();
// Specify the initial capacity of the hash table instance as 20 elements.
Hashtable ht1 = new Hashtable (20 );
// A hash table instance with an initial capacity of 20 elements and a loading Factor of 0.8 has a large loading factor, and the automatic expansion capacity of the hash table is also large.
Hashtable ht2 = new Hashtable (20, 0.8f );
// Instantiate a SortedList.
SortedList sl = new SortedList ();
Sl. Add ("Key 1", "key value 1 ");
Sl. Add ("Key 2", "Key 2 ");
Sl. Add ("key 3", "key 3 ");
// Input parameters that implement the IDictionary interface to create a hash table.
Hashtable ht3 = new Hashtable (sl );
}
}
}

 

Set> hash table class Hashtable> Get hash table Value

Code Using System;
Using System. Collections. Generic;
Using System. Text;
Using System. Collections;

Namespace useHashtable
{
Class Program
{
Static void Main (
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.