Checking .NET Type

Jun 18, 2014 at 3:04 PM
Hi, how do i compare a .NET type in V8ScringEngine?

For example, i want to compare if thefollowing types are equal

var x = new Order();
var y = new Customer();

if (typeof(x) === typeof(y){


This will always returns true because typeof(x) or typeof(y) is always an "object".
Jun 19, 2014 at 2:23 AM
Edited Jun 27, 2014 at 10:01 PM
Hi ravetam,

If you set ScriptEngine.AllowReflection to true, you can use Object.GetType() for his purpose.
if (x.GetType() === y.GetType()) {
    // do something
Good luck!
Jun 19, 2014 at 3:12 PM
that works, thanks!