Copy of a set

Source: Internet
Author: User

Using system;
Using system. collections;
Using system. Collections. Specialized;
Copying a namespace set

/// Summary of class1.

Class class1
Static void main (string [] ARGs)
Namevaluecollection namedvcoll = new namevaluecollection ();
Namedvcoll. Add ("Xiaohua", "13510532686 ");
Namedvcoll. Add ("Xiaohua", "62658888 ");
Namedvcoll. Add ("Xiao Yang", "1361030486 ");
Namedvcoll. Add ("Xiao Yang", "62293218 ");
Foreach (string key in namedvcoll. Keys)
Console. writeline ("name = {0}, phone = {1}", key, namedvcoll [Key]);
Console. writeline ("the set of named values obtained after copying ");
String [] arr = new string [namedvcoll. Count];
Namedvcoll. copyto (ARR, 0 );
For (INT I = arr. getlowerbound (0); I {
Console. writeline ("name = {0}, phone = {1}", namedvcoll. allkeys [I], arr [I]);
Hashtable hhtable = new hashtable ();
Hhtable ["Xiaohua"] = "Beijing ";
Hhtable ["Xiao Yang"] = "Nanjing ";
Console. writeline ("clone hash table ");
Foreach (Object key in hhtable. Keys)
Console. writeline ("name = {0}, address = {1}", key, hhtable [Key]);
Hashtable hhcloned = (hashtable) hhtable. Clone ();
Hhtable ["Xiaohua"] = "Shanghai ";
Console. writeline ("clone and modify the initialization hash table ");
Foreach (Object key in hhtable. Keys)
Console. writeline ("name = {0}, address = {1}", key, hhtable [Key]);
Console. writeline ("clone Kazakh Greek table after hash table initialization after modification ");
Foreach (Object key in hhcloned. Keys)
Console. writeline ("name = {0}, address = {1}", key, hhcloned [Key]);
Console. Read ();

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: 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.