Question: I'm developing ASP.NET application and I need to calculate maths expressions like 

```
16+25*(15.38-12.16)

```

which is entered in a text box control and to get result in other text box or label or wherever.

I tried some of these, but not of much help <https://stackoverflow.com/questions/tagged/equation+c%23>

Is there a possible way to do it?

Answer: 
You might be able to use [`DataTable.Compute()`](http://msdn.microsoft.com/en-us/library/system.data.datatable.compute.aspx) but it can only handle simple equations.
This should work:

C#

```
private double CalcEquation(string equation)
{
    DataTable tempTable = new DataTable();

    var result =  tempTable.Compute(equation, "");
}

```

VB.Net

```
Private Sub CalcEquation(ByVal equation As String)

    Dim tempTable As New DataTable()

    Dim result As Object = tempTable.Compute(equation, "")

End Sub

```
You could use the [NCalc](http://ncalc.codeplex.com) library. It can handle more complex functions.

```
using System;
using NCalc;
namespace NCalcExample
{
    class Program
    {
        static void Main(string[] args)
        {
            string evalString = "sin(2.0)+3";
            Expression e = new Expression(evalString, EvaluateOptions.IgnoreCase);
            Console.WriteLine(e.Evaluate());
        }
    }
}

```