在.net里 字符串如何按表达式计算

来源:百度知道 编辑:UC知道 时间:2024/06/30 20:24:15
如:"8*3+1"

得到值为 25

///只帮你简单地写一下吧,另外还要考虑优先级问题。
///今天没时间了,改天帮你写各完整的吧

using System;
using System.Collections.Generic;
using System.Text;

namespace ConsoleApplicationTest
{
public class Class2
{
static void Main()
{
string m_formula = null;
Console.WriteLine("\n\tplease input a formula:\n");
Console.Write("\t");
m_formula = Console.ReadLine();
Analyse simple = new Analyse(m_formula);
Console.WriteLine("\n\tThe result is:\t{0}",simple.DoEvent());
Console.ReadLine();
}
}

public class Tool
{
/// <summary>
/// 字符是否数字
/// </summary>
/// <param name="newChar"></param>
/// <returns></returns>