gpt4 book ai didi

arrays - VB.NET 在数组中查找字符串

转载 作者:行者123 更新时间:2023-12-03 22:44:42 24 4
gpt4 key购买 nike

这个问题在这里已经有了答案:





How can I search an array in VB.NET?

(9 个回答)


8 年前关闭。




我是 VB.net 的新手,通常是 Python 或 Matlab 程序员。我已经开始在 VB.Net 中编程。我正在努力在不遍历 for 循环的情况下引用数组中字符串的索引

如何在一行中找到数组中的条目?我的想法是这样..

Dim indx As Integer
Dim MyArray() As String

indx = MyArray.find("ThisEntry")

或索引
indx = MyArray.indexof("ThisEntry")

到目前为止,我发现的只是在声明变量后直接描述方法的函数?我错过了什么吗?或者逻辑没有意义?

最佳答案

这样做,在您的阵列上有一些内容后,现在是空的:

Dim result As String = Array.Find(MyArray, Function(s) s = "ThisEntry")

获取索引:
Dim index As Integer = Array.FindIndex(MyArray, Function(s) s = "ThisEntry")

关于arrays - VB.NET 在数组中查找字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16713474/

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