//string索引器
using System;
using System.Collections;
namespace index3N
{
    class index3
    {
        Hashtable ht = new Hashtable();
        public string this[string index]
        {
            get { return ht[index].ToString(); }
            set { ht.Add(index, value); }
        }

        static void Main()
        {
            index3 myIndex3 = new index3();
            myIndex3["A001"] = "aaa";
            myIndex3["A002"] = "bbb";
            myIndex3["A003"] = "ccc";

            Console.WriteLine(myIndex3["A001"]);
            Console.WriteLine(myIndex3["A002"]);
            Console.WriteLine(myIndex3["A003"]);

        }
    }
}

posted on 2008-01-25 15:00  glave  阅读(179)  评论(0)    收藏  举报