How can I access a collection returned from a CSharp COM object in Classic ASP JScript?
See the question and my original answer on StackOverflowWhat you can do is return a hand made collection, like this:
[ComVisible(true)] // may be optional depending on your other assembly settings
public class ResultList
{
private List<Result> _innerList;
internal ResultList(...parameters...)
{
_innerList = ...
}
public int Count
{
get
{
return _innerList.Count;
}
}
public Result this[int index] // will be named "Item" in COM's world
{
get
{
return _innerList[index];
}
}
}
That you can use like this:
var results = oMyObject.GetResults();
for (var i = 0; i < results.Count; i++) {
Response.Write("<br /><i>('" + results.Item(i).Value + "', '" + results.Item(i).ID + "')</i>");
}