如何在C#中使用EVAL方法

 

   decimal a  = 1;
   decimal b = 2;
   string ev  = "a + b";
   System.Data.DataTable dt = new System.Data.DataTable();
   dt.Columns.Add("a",typeof(decimal));
   dt.Columns.Add("b",typeof(decimal));
   dt.Rows.Add(new object[]{a,b});
   dt.Columns.Add("c",typeof(decimal));
   dt.Columns["c"].Expression = ev;
   MessageBox.Show(dt.Rows[0]["c"].ToString());
 
 
谢谢山西的马泽KUI,给了我良好的想法!

posted on 2006-11-15 12:28  戴玮  阅读(1345)  评论(2编辑  收藏  举报

导航