Using system;
Using system. collections;
Using system. Collections. Specialized;
Copying a namespace set
{
///
/// Summary of class1.
///
Class class1
{
[Stathread]
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 ();
}
}
}