如何在运行时在C#中以字符串格式评估布尔表达式的结果? [英] How can I evaluate the result of a boolean expression in string format on runtime in C#?

查看:97
本文介绍了如何在运行时在C#中以字符串格式评估布尔表达式的结果?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

让我说我从一个文件中读取这个条件:

  Condition =Person.Value.Status == 9

如何在运行时检查此条件是否为真,Person是我的代码中的一个类?

解决方案

虽然我没有亲自做这个我自己,这可能是您正在寻找的。这是一个表达评估者,这是我认为你想要实现的。


Lets say I read this condition from a file:

Condition = "Person.Value.Status == 9"

How can I check if this condition is true in runtime providing that "Person" is a class in my code?

解决方案

While I haven't personally done this myself, this might be what you're looking for. It's an expression evaluater which is what I think you are trying to achieve.

这篇关于如何在运行时在C#中以字符串格式评估布尔表达式的结果?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆