Neither C# , or the .NET Framework doesn't have a readily available eval()
function where you can just pass in any random expression. Traditionally, people would use the classes and methods in the CodeDom namespace of the .NET Framework to dynamically compile and run code, but there are newer options with building expression trees, or using Roslyn.
不过,那些也许会过分杀了。您想要评估的表达式可能足够简单,以至于不需要动态编译和运行代码。您也许可以象征性地进行评估,就像对后缀进行后缀的标准CS练习之一一样,然后进行后缀评估。