This project has moved and is read-only. For the latest updates, please go here.

Checking .NET Type

Jun 18, 2014 at 4: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 3:23 AM
Edited Jun 27, 2014 at 11: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 4:12 PM
that works, thanks!