string a="<";
int a1=1;
int a2=3
int x=2;
//希望 1<2<3 判断
string reslut =a1+a+x+"&&"+x+a+a2;bool b=convert.toboolen(reslut);
结果无法转换 该如何?
以上变量都是动态获得!!!
int a1=1;
int a2=3
int x=2;
//希望 1<2<3 判断
string reslut =a1+a+x+"&&"+x+a+a2;bool b=convert.toboolen(reslut);
结果无法转换 该如何?
以上变量都是动态获得!!!
解决方案 »
- 紧急求助~~~搞过_ 读写智能IC卡 的帮忙看下
- 关于数据存储问题
- 如何想实现这样的数据绑定 c# DataSet
- MSDAORA.1连接Oracle问题,急1
- 绝对的想散分..还有不到8000分.lycoo..散分接龙001
- 用C#编写windows窗口程序时,如何创建"自定义的windows 窗体模板",并使用.
- 怎么将XML文件中的数据序列化成字符串,并能反序列化
- 在串口通信中,给设备发送命令,DataReceive为什么要分两次来接收数据
- www.codeforge.cn 谁有账号帮忙下载个链接吧 万分感谢 在线等 百分求助
- xml文档等价性如何判断???????(100分)
- 冰天雪地跪地求教!!!!!
- 使用vs2008打包,打包以后怎么生成.deploy的扩展名文件?
/// <summary>
/// 采用动态编译,计算表达式的结果
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void button6_Click(object sender, EventArgs e)
{
// 声明要计算C#代码,要求必须完整的C#代码
string strCode = @"
using System;
namespace ParseEx
{
public class ParseExC
{
public static double GetValue()
{
return 1+5*8-(Math.Sin(12)*2.5);
}
}
}"; CodeDomProvider comp = new CSharpCodeProvider();
CompilerParameters cp = new CompilerParameters(); StringBuilder codeBuilder = new StringBuilder();
codeBuilder.AppendLine(strCode); cp.ReferencedAssemblies.Add("System.dll");
cp.GenerateExecutable = false;
cp.GenerateInMemory = true;
CompilerResults cr = comp.CompileAssemblyFromSource(cp, codeBuilder.ToString());
if (cr.Errors.HasErrors)
{
MessageBox.Show("Error!");
}
else
{
Assembly a = cr.CompiledAssembly;
if (a != null)
{
Type t = a.GetType("ParseEx.ParseExC");
if (t != null)
{
// 因为是静态调用,不需要创建实例了
// object mode = a.CreateInstance("Mode");
MethodInfo mi = t.GetMethod("GetValue", BindingFlags.Static | BindingFlags.Public);
if (mi != null)
{
double d = (double)mi.Invoke(null, null);
MessageBox.Show(d.ToString());
}
}
}
}
}
int a1 = 1;
int a2 = 3;
int x = 2;
DataTable dt = new DataTable();
object obj = dt.Compute(string.Format("{0}{1}{2} And {3}{4}{5}", a1, a, x, x, a, a2), string.Empty);
if (obj != null)
{
if (Convert.ToBoolean(obj) == true)
{
System.Console.Write("True");
}
else
{
System.Console.Write("False");
}
}