Which collection interface should I use in .NET for COM-interop?

Posted by jhominal on Stack Overflow See other posts from Stack Overflow or by jhominal
Published on 2010-06-03T08:51:03Z Indexed on 2010/06/03 8:54 UTC
Read the original article Hit count: 388

Filed under:
|
|

That is a followup from my previous question, but you don't need to read it to understand that one.

I'm designing an interface in .NET that would be consumed from COM applications (mainly VB6, but Visual C++ 6 is also a possibility) and I would like to use Collection types as argument and return types for the methods in the interface.

Questions:

  1. What happens to the VB6 built-in collection types (arrays, collections, dictionaries) when they go through interop? My current guess is that:

    • arrays -> System.Array
    • collections -> Microsoft.VisualBasic.Collection
    • dictionaries -> System.Collections.Hashtable

    Is that correct?

  2. Which interfaces should I use as return types? IEnumerable, ICollection, IList, IDictionary? Would I be able to do a For Each in VB6 to iterate over these interfaces? Should I use the generic or non-generic variants of the interfaces?

© Stack Overflow or respective owner

Related posts about .NET

Related posts about vb6