gpt4 book ai didi

vb.net - 如何在 For Each...Next 循环中获取对象的索引?

转载 作者:行者123 更新时间:2023-12-04 08:59:32 25 4
gpt4 key购买 nike

我使用以下语法循环遍历列表集合:

For Each PropertyActor As JCPropertyActor In MyProperty.PropertyActors

i = IndexOf(PropertyActor)
Next

如何获取循环中当前对象的索引?我正在使用 IndexOf(PropertyActor) 但这似乎效率低下,因为当我已经有了可用的对象时它会搜索集合!

最佳答案

AFAIK 由于这会将对象从集合中拉出,因此您必须返回集合才能找到它。

如果您需要索引,而不是使用 for 每个循环,我将只使用遍历索引的 for 循环,以便您知道您拥有什么。

关于vb.net - 如何在 For Each...Next 循环中获取对象的索引?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/205986/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com