1

If I have an array like

Dim list As String()

and list is read from a file with

list = Split("filehere.txt", ",")

and I use something like

If list.Contains("string") then
code here
End If

can I find out which string of the array "string" came from, for example: string(0) or string(16)

4

1 に答える 1

5

.NET では、リスト内のオブジェクトの場所を見つけるために、IndexOf.

オブジェクトが見つからない場合、メソッドは -1 を返します。これにより、同じメソッドを使用して、リストにオブジェクトが含まれているかどうか、およびその場所を確認できます。

于 2013-04-04T21:31:16.663 に答える