【问题标题】:VB.NET indexof not finding string()VB.NET indexof 找不到字符串()
【发布时间】:2017-10-19 02:19:43
【问题描述】:

这是我的代码:

Dim list As New List(Of String)        
'populate list with string values

Dim list2 As New List(Of String())

    For i As Integer = 0 To list.Count - 1
        list2.Add({list.Item(i), "temp"})
    Next

    for x as integer = 0 to list.count
        Dim test1 = list2.indexof({list.item(x), "temp"}) '***this line is returning -1
    next

虽然我可以清楚地看到 list2 在其第一个索引中包含字符串:

“加里”和“临时”

当我搜索包含以下内容的索引时,它拒绝返回 -1 以外的索引:

{“加里”,“临时”}

【问题讨论】:

    标签: list search indexing


    【解决方案1】:

    刚刚重组我的代码以避免这个问题——现在一切都很好。

    我不确定为什么这不起作用;如果有人来寻找解决方案。

    【讨论】:

      猜你喜欢
      • 2018-07-22
      • 2011-04-09
      • 2018-09-03
      • 2018-06-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-06-09
      相关资源
      最近更新 更多