DataTable.Compute自由计算表达式
public static object Eval(string AExpression) { try { return new System.Data.DataTable().Compute(AExpression, ""); } catch { return null; } } private void button1_Click(object sender, EventArgs e) { lblResult.Text = Eval("(1.5+2.5)*2/4").ToString(); }
posted on 2009-06-29 11:23 Lionheart Zhang 阅读(476) 评论(0) 编辑 收藏 举报