把:
"aa","xxxxx"
"kk","xxxxx"
...放在一个二维容器中(例如哈西表等),然后通过key值找到value!例如:在数据库中获取"aa",然后在二维容器中寻找key值为"aa"的Value,就获取了xxxxx!

解决方案 »

  1.   


    if(bb="aa")
    {
    bb = aa;
    }==================================
    弯弯的月亮小小的船,小小的船,两头尖,我在小小的船里坐,只看见闪闪的
    星星蓝蓝的天.
      

  2.   

    关键"xxxxx"是动态的,对每个人都是不一样的
      

  3.   

    我想应该有一个类似eval的函数,但没有搜索到。
      

  4.   

    assume aa is a member variable (otherwise, it is not possible), you can use Reflection, for example, something like         String aa = "xxxxxx";         ....
    String bb = "aa";
             Type t = this.GetType();
             FieldInfo fi = t.GetField(bb);
          
             string s = (string)fi.GetValue(this);or create a JScript DLL that exposes the Eval function. You can then use it in C#.
          
      

  5.   

    让我想到了Javascript中的eval()
      

  6.   

    if(bb="aa")
    {
    bb = aa;
    }
    String aa = "xxxxxx";  关键"xxxxx"是动态的? 可是aa是不变得呀
      

  7.   

    Javascript中的eval()函數可以解決
      

  8.   

    TO: saucer(思归) 
    在执行完 FieldInfo fi = t.GetField(bb);  后 fi为 null 啊?怎么办?
      

  9.   

    注意,上面已经说了,aa必须是类的成员才行如果fi是null,表明这成员"aa"不存在或是私有成员,那么试试 FieldInfo fi = t.GetField(bb, BindingFlags.Instance| BindingFlags.NonPublic );