如何在VB6中使用C#集合 [英] How do I use a C# collection in VB6
本文介绍了如何在VB6中使用C#集合的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要在C#中定义一组对象,我也可以在VB6中使用它。我需要VB6应用程序来填充集合,然后C#应用程序将读取集合并使用数据。
我已经成功地以这种方式使用了简单的类但是想要用集合做同样的事情。
I need to define a collection of objects in C# that I can also use in VB6. I need the VB6 app to populate the collection and the C# app will then read the collection and use the data.
I have succesfully used simple classes in this way but want to do the same thing with collections.
推荐答案
我相信你只能在vb.net而不是c#中使用集合。 C#有Collection,但你必须指定类型,例如Collection< yourclass>,VB6不能使用这个结构!
在vb.net中,你可以用属性创建一个通用列表是Collection,然后你可以在这个集合中添加任何对象并在VB6中使用它。
I believe you can only use collection in vb.net instead of c#. C# has Collection, but you have to specify the type, for example Collection<yourclass>, and this structure cannot be used by VB6!
In vb.net, you can create a generic list with a property is Collection, then you can add any object to this collection and comsume it in VB6
Public Class GenericList
Private _list As New Collection
Public Property List() As Collection
Get
Return _list
End Get
Set(value As Collection)
_list = value
End Set
End Property
End Class
可以尝试使用互操作 - C#Com [ ^ ]。
This can be tried using interop - C# Com[^].
这篇关于如何在VB6中使用C#集合的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文