J# 集合到 VB .NET 集合
我有一系列返回 J# 数据类型的 API 调用。我已经能够很好地转换大多数数据类型(整数、布尔值、双精度值、浮点值等)。
我现在需要做的是将 java.Util.Collection 转换为 VB .NET 集合(ArrayList?)
这是我的尝试:
Public Function MakeDotNETCollection(ByVal javaCol As java.util.Collection) As Collection
Dim dotNetCol As Collection
If Not javaCol Is Nothing Then
dotNetCol = New Collection
Dim it As IEnumerator = javaCol.iterator()
For Each it In CType(javaCol, Collection)
dotNetCol.Add(it.Current)
Next it
End If
Return dotNetCol
End Function
我不断收到运行时错误“无法将类型为 'AbstractListlistIterator' 的对象转换为类型为 'System. Collections.IEnumerator 有什么想法吗?
I have a series of API calls that are returning J# data types. I have been able to convert most of the data types (Integer, Boolean, Double, Float, etc) just fine.
What I need to do now is convert a java.Util.Collection to a VB .NET collection (ArrayList?)
Here is my attempt:
Public Function MakeDotNETCollection(ByVal javaCol As java.util.Collection) As Collection
Dim dotNetCol As Collection
If Not javaCol Is Nothing Then
dotNetCol = New Collection
Dim it As IEnumerator = javaCol.iterator()
For Each it In CType(javaCol, Collection)
dotNetCol.Add(it.Current)
Next it
End If
Return dotNetCol
End Function
I keep getting a runtime error "Unable to cast object of type 'AbstractListlistIterator' to type 'System.Collections.IEnumerator. Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
未经测试,但应该可以工作:
Not tested, but should work: