• 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  
  • 相关阅读:
    guaguia
    webapp手机移动端开发技巧
    两个数组对象对比
    json 根据某个子,寻找父节点的算法
    递归写法
    数组归类
    视频点击按钮下载
    微信小程序 直接跳转到首页
    iframe 跨域传值
    判断对象是否为空
  • 原文地址:https://www.cnblogs.com/QLJ1314/p/2622911.html
Copyright © 2020-2023  润新知