This project has moved. For the latest updates, please go here.

Byte converted to Int

Jun 22, 2014 at 5:30 PM
Is there anyway I can create a byte object inside V8?

I tried
var b = Byte.Parse('162');
But b has been converted to a Number.
Jun 22, 2014 at 5:46 PM
you can add a function
addhostobject("int", new Func<object, int>(o => Convert.ToInt32(o));
Jun 23, 2014 at 1:52 PM
Hi ravetam,

There are a couple of ways to do it. First, you can use HostFunctions.toByte():
engine.AddHostObject("host", new HostFunctions());
    var b = host.toByte(162);
Another way is to use a host variable:
engine.AddHostType("Byte", typeof(Byte));
    var b = host.newVar(Byte);
    b.value = 162;
Jun 27, 2014 at 4:04 AM
that works, thanks!