I am trying to make a windows C# form which uses some functions that I wrote inside Mathematica.
Suppose that we have the following package:
BeginPackage["second`"];
Begin["`Private`"];
SecondDegre[a_, b_, c_] := Module[{delta, x1, x2},
delta=b^2-4*a*c;
x1=(-b + delta^0.5)/(2 a);
x2=(-b - delta^0.5)/(2 a);
{x1,x2}
];
End[];
EndPackage[];
I already tested this package in Mathematica - it works, successfully made a connection C# to Mathematica by adding reference and tested this example:
using Wolfram.NETLink;
private void button1_Click(object sender, EventArgs e)
{
Expr symbolPlus = new Expr(ExpressionType.Symbol,"Range");
Expr e1 = new Expr(symbolPlus, 1, 4,1);
IKernelLink ml = MathLinkFactory.CreateKernelLink();
ml.WaitAndDiscardAnswer();
// ml is a KernelLink
string result = ml.EvaluateToOutputForm(e1, 0);
textBox3.Text = result ;
ml.Close();
}
The output after execution is:
{1,2,3,4}
My question is :
How can I run the Mathematica package inside C# in order to use the SecondDegre
like i have used the Range
in the previous example?