我这么写,但是不对。
private static string[][] engine = {{"google","http://www.google.com"},{"baidu","http://www.baidu.com"},{"yisou","http://www.yisou.com"},{"zhongsou","http://www.zhongsou.com"}};
我希望用的时候

engine["baidu"]就能取出http://www.baidu.com当然我要用变量就是这样engine = engine[变量];

解决方案 »

  1.   

    使用 Hashtableusing System.Collections;    Hashtable h = new Hashtable();
        h.Add("key1", "text1");
        h.Add("key2", "text2");
        string myData = h["key2"].ToString();myData里存放的就是"text2"
      

  2.   

    楼上的不完善
    public class myclass{
    private HashTable ht;
    public object this[string strvalue]
    {
      get{
         return ht[strvalue];
      }
    }
    ....
    }
    use object val = myclass["123"];
      

  3.   

    使用.NET 中提供的StringDictionary
      

  4.   

    使用数组可能就不能实现此功能了,可以使用 System.Collections 名字空间中的类
      

  5.   

    数组也可以,只不过要自己写查询语句
    其实就是C#的索引器
    ms-help://MS.VSCC.2003/MS.MSDNQTR.2003FEB.2052/csref/html/vclrfindexedpropertiespg.htm
      

  6.   

    System.Collections.Hashtable ht = new System.Collections.Hashtable();
    ht.Add("key1","www.sina.com.cn");
    ht.Add("key2","www.sohu.com.cn");
    ht.Add("key3","www.tom.com.cn");
    string tstr = ht["key1"].ToString();