Many people will say that languages are only different in grammar. In fact, everyone ignores one point. If you choose a language, the language provider will definitely provide a lot of system libraries for this language.
Next is a simple example to combine Jscript.net and C# is used to calculate an expression.
Question requirements: Input a series of simple expressions and output the value.
For example, 2+4*7 returns 30.
Note that we all use .net to implement it, haha.
1. Create a new jscript file, CustomEval.js
// JScript source code
classCustomEval
{
static function eval(strExp)
{
return eval(strExp);
}
}Then go to the .net command prompt and compile the js into a .net assembly
jsc /t:library CustomEval.js
Then a CustomEval.dll standard .net assembly is generated.
The call is also very simple.
Create a new project, reference the dll, and also reference MIcrosoft.Jscript.dll
with the following code:
class Program
{
static void Main(string[] args)
{
Console.WriteLine(CustomEval.eval("2+4*7"));
}
}
Haha, the results are out.
Similar to how you use C#, you can use many functions provided by Microsoft.Visualbasic.*.dll. C# takes advantage of the features of VB