zoukankan      html  css  js  c++  java
  • C# hashtable 哈希表

    实现了,ICollection和IEnumerable接口。
         方法
         Add(object,object)
         通过索引来获得值    

    我们学习吧...

    View Code
     1 using System;
     2 using System.Collections;
     3  public class HashTable
     4  {
     5      public static void Main()
     6      {
     7          Hashtable ht = new Hashtable();
     8          ht.Add("three","石头");
     9          ht.Add(5,5);
    10          ht.Add(9,"hdsuooe");
    11          foreach( object c in ht.Values)
    12         {
    13           Console.WriteLine(c.ToString());
    14          }
    15          foreach(object d in ht.Keys)
    16         {
    17           Console.WriteLine(d.ToString() );
    18          }
    19         
    20  }
    21  public static void Test()
    22 {
    23      Hashtable ht = new Hashtable();
    24      ht.Add("one","one");
    25      ht.Add("two",2);
    26      ht.Add(3,3);
    27      //读取值
    28      object o = ht[0];
    29      ht[0] = "哈哈";
    30      Console.WriteLine(ht[0]);
    31      var collection = ht.Keys;
    32      var collection1 = ht.Values;
    33      foreach(object a in collection)
    34     {
    35          Console.WriteLine(a.ToString());
    36      }
    37      foreach(object b in collection1)
    38     {
    39        Console.WriteLine(b.ToString());
    40      }
    41   }
    42     
    43 }
    44  
  • 相关阅读:
    linux 网卡配置详情
    linux ftp 添加用户及权限管理
    mysql 权限管理
    linux ftp 安装及相关命令
    linux find 命令
    linux yum 安装及卸载
    linux svn 安装
    cssText方式写入css
    addLoadEvent
    mobile体验效果:增加点击后反馈
  • 原文地址:https://www.cnblogs.com/QLJ1314/p/2622911.html
Copyright © 2011-2022 走看看