Language is by no means a different syntax. NET version evaluates expression value

Source: Internet
Author: User
Tags eval expression net net command version
Grammar

Many people can say that language is just a grammatical difference, in fact, everyone ignores a point to choose a language, the language provider will certainly provide a lot of system library to the language.

The next simple example is to combine JScript.NET and C # to compute an expression.

Problem requirements: Enter a string of simple expressions, output values.
Like 2+4*7, return 30.

Note that we all use. NET to achieve, hehe.

1. Create a new JScript file, Customeval.js

JScript Source Code
Class Customeval
{
static function eval (STREXP)
{
Return eval (STREXP);
}

Then to the. NET command prompt, compile the JS as a. NET assembly

Jsc/t:library Customeval.js
It then generates a CustomEval.dll standard. NET assembly.

The call is also simple.
Creates a new project, references the DLL, and also references MIcrosoft.Jscript.dll

The following code:

Class Program
{
static void Main (string[] args)
{
Console.WriteLine (Customeval.eval ("2+4*7"));
}
}
Oh, the result came out.

Similar to the features you can use C # to provide with many microsoft.visualbasic.*.dll. C # using the characteristics of VB



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.