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

New Post: Setting Decimal property of Object [V8]

$
0
0
Greetings!

JavaScript numbers are floating-point and therefore not implicitly convertible to decimal (see here for more information).

You can assign a decimal property as follows:
engine.AddHostObject("host", new HostFunctions());
engine.Execute("MyObject.Price = host.toDecimal(1.5)");
By the way, your first example works because ClearScript converts JavaScript numbers to managed integers when doing so results in no data loss, and integers are implicitly convertible to decimal.

Good luck!

Viewing all articles
Browse latest Browse all 2297

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>