谁做过这样的逻辑 例如类Value Value.A=1Value.B=5 Value.C=10 数据库中取出的运算公式串为(A=1) and (B>2) and (C<6)怎么样替代算出逻辑值来。。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 找到了一个 public class Eval { public static object GetValue(string value) { string codeSnippet = "using System; " + "\r\n" + "namespace CzG {" + "\r\n" + " public class Eval" + "\r\n" + " {" + "\r\n" + " public Eval(){} " + "\r\n" + " public object GetValue()" + "\r\n" + " {" + "\r\n" + " return " + value + ";" + "\r\n" + " }" + "\r\n" + " } }"; CodeSnippetCompileUnit unit = new CodeSnippetCompileUnit(codeSnippet); ICodeCompiler compiler = new CSharpCodeProvider().CreateCompiler(); CompilerParameters para = new CompilerParameters(); para.ReferencedAssemblies.Add("System.dll"); para.GenerateInMemory = true; para.GenerateExecutable = false; para.OutputAssembly = "Eval.dll"; Assembly asm = compiler.CompileAssemblyFromDom(para, unit).CompiledAssembly; Type type = asm.GetType("CzG.Eval"); MethodInfo mi = type.GetMethod("GetValue", BindingFlags.Public | BindingFlags.Instance); object obj = asm.CreateInstance("CzG.Eval"); return mi.Invoke(obj, null); } } bool a= Convert.ToBoolean(Eval.GetValue("125<23" )); 是这个意思?(Value.A==1)& (Value.B>2) & (ValueC <6) 将1,2,6作为类初始化时的参数new Value(1,2,6),如果要加入逻辑符号的话,就改为new Value(1,2,6,sya,syb,syc)将A B C换为属性,在赋值的时候可以判断是否符合条件 gridview怎么动态显示“编辑,删除”这些字段 c#中的static void Main(string[] args)参数args .NET虚拟技术。 请各位给推荐一下几本相关的教材 30分求教C#处理Xml的问题 数据库死锁,研究好几天了,达人们,帮个忙~~ ■哇 发现VC#重大BUG 事件根本不响应 !! 千真万确 简单问题,送分,在线急等!!! 解决概念问题,关于soap,消息,socket 请教:怎么用http传输文件 啊? c#创建站点,并且设置这个站点的应用程序池 100分求解方程组解法
public class Eval
{
public static object GetValue(string value)
{
string codeSnippet = "using System; " + "\r\n" +
"namespace CzG {" + "\r\n" +
" public class Eval" + "\r\n" +
" {" + "\r\n" +
" public Eval(){} " + "\r\n" +
" public object GetValue()" + "\r\n" +
" {" + "\r\n" +
" return " + value + ";" + "\r\n" +
" }" + "\r\n" +
" } }";
CodeSnippetCompileUnit unit = new CodeSnippetCompileUnit(codeSnippet);
ICodeCompiler compiler = new CSharpCodeProvider().CreateCompiler();
CompilerParameters para = new CompilerParameters();
para.ReferencedAssemblies.Add("System.dll");
para.GenerateInMemory = true;
para.GenerateExecutable = false;
para.OutputAssembly = "Eval.dll"; Assembly asm = compiler.CompileAssemblyFromDom(para, unit).CompiledAssembly; Type type = asm.GetType("CzG.Eval");
MethodInfo mi = type.GetMethod("GetValue", BindingFlags.Public | BindingFlags.Instance); object obj = asm.CreateInstance("CzG.Eval");
return mi.Invoke(obj, null);
}
}
bool a= Convert.ToBoolean(Eval.GetValue("125<23" ));
(Value.A==1)& (Value.B>2) & (ValueC <6)