Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Windows.Forms;
- using MSScriptControl;
- namespace Blog.Script
- {
- public partial class Form1 : Form
- {
- public Form1()
- {
- InitializeComponent();
- }
- private void Form1_Load(object sender, EventArgs e)
- {
- ScriptControlClass script = new ScriptControlClass();
- script.Language = "JScript";
- script.AddCode("var v = 10;");
- StringBuilder js = new StringBuilder();
- js.AppendLine("function max(x,y){ return x > y ? x : y; }");
- js.AppendLine("max(v,3);");
- string result = "";
- try
- {
- result = script.Eval(js.ToString()).ToString();
- }
- catch
- {
- result = script.Error.Line + "," + script.Error.Column + " " + script.Error.Description;
- }
- MessageBox.Show(result);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement