Skip to content

Commit 7b081d7

Browse files
committed
Add NCalc documentation with examples for expression evaluation
1 parent 85cadd3 commit 7b081d7

1 file changed

Lines changed: 25 additions & 0 deletions

File tree

docs/Packages/NCalc.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
## Overview
2+
- NCalc is a fast and lightweight expression evaluator library for .NET
3+
- designed for flexibility and high performance.
4+
- It supports a wide range of mathematical and logical operations.
5+
- Use `dotnet add package NCalcSync` to install nuget package
6+
- Add `using NCalc;`
7+
8+
## Simple Expression
9+
10+
```csharp
11+
var expression = new Expression("2 + 3 * 5");
12+
Console.WriteLine($"Result: {expression.Evaluate()}");
13+
```
14+
## Equations with variables
15+
```csharp
16+
string exprText = "2 + 3 * x - Sin(y)";
17+
18+
var expr = new Expression(exprText);
19+
20+
expr.Parameters["x"] = 4;
21+
expr.Parameters["y"] = Math.PI / 2;
22+
23+
var result = expr.Evaluate(); // result = 2 + 3*4 - 1 = 13
24+
Console.WriteLine(result);
25+
```

0 commit comments

Comments
 (0)