Quantcast
Channel: ClearScript
Viewing all articles
Browse latest Browse all 2297

New Post: Possible to add a global function?

0
0
Hello UweKeim,

Yes, this is possible. Simply add an object of a delegate type:
engine.AddHostObject("add", new Func<int, int, int>(delegate(int a, int b) { return a + b; }));
You can also use a lambda expression to accomplish the same thing:
engine.AddHostObject("add", new Func<int, int, int>((a, b) => a + b));
Good luck!

Viewing all articles
Browse latest Browse all 2297

Latest Images

Trending Articles





Latest Images