Hello ClearScript,
I have a host object ProductManager and it provides a function to search products:
In C#:
I have a host object ProductManager and it provides a function to search products:
public IEnumerable<Product> Search(string condition);
How can I loop through the IEnumerable result in JavaScript likes following:In C#:
ProductManager manager = new ProductManager();
engine.AddHostObject("productManager", manager );
engine.AddHostType("console", typeof(Console));
In JavaScript:var results = productManager.Search("price > 100");
for (XXXXXXXX) <- how to write the for statement here?
{
......
}
Should I use the ToArray() first just likes the following?var results = productManager.Search("price > 100").ToArray();
for (var i = 0; i < results.Length; i++)
{
console.WriteLine(results[i].Name);
}