vb.net相当于vb6的函数属性

时间:2016-01-28 12:12:18

标签: vb.net vb6 attributes vb6-migration

我在vb6中有以下课程:

Public Function NewEnum()
    Attribute NewEnum.VB_UserMemId = -4
    Attribute NewEnum.VB_MemberFlags = "40"

    NewEnum = mcolFields.[_NewEnum]

End Function

vb.net?中的等效属性是什么?我知道你必须将属性放在<>中,我也发现了this SO帖子,但它并没有解决我的问题。

2 个答案:

答案 0 :(得分:3)

GetEnumerator()是完全等价的。它在<ComVisible(True)>代码中以NewEnum形式公开。只需实现System.Collections.IEnumerable接口,即非通用接口。

答案 1 :(得分:1)

有关此内容的一些信息,请访问:https://christopherjmcclellan.wordpress.com/2015/04/21/vb-attributes-what-are-they-and-why-should-we-use-them/

  

VB_UserMemId还有一个特殊值,该值为-4。   负4始终表示正在标记的功能应该   返回[_NewEnum]枚举器。

我想说在这种情况下你可以忽略它们。所以你的等价物应该是这样的:

Public Function NewEnum() As mcolFields
    Return New mcolFields
End Function