casting

Mar 4, 2014 at 5:35 PM
hi, how can i cast types?
like these in c#: (string)helloworld;
or these: Convert.ChangeType(helloworld, typeof(string));
Coordinator
Mar 5, 2014 at 2:57 PM
Hi furesoft,

You can expose System.Convert to the script engine, or use HostFunctions.cast(). Keep in mind however that numbers are converted to native JavaScript or VBScript values when brought into the script engine. If you need to invoke a host method that requires a numeric argument of a specific .NET type, you may have to use a function such as HostFunctions.toInt16() to ensure proper method binding.

Good luck!