用的IndexOf在VB.NET String数组 [英] IndexOf with String array in VB.NET

查看:2679
本文介绍了用的IndexOf在VB.NET String数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将如何找到一个项目在以下code中的字符串数组索引:

How would I find the index of an item in the string array in the following code:

Dim arrayofitems() as String
Dim itemindex as UInteger
itemindex = arrayofitems.IndexOf("item test")
Dim itemname as String = arrayofitems(itemindex)

我想知道我怎么会找到一个项目的索引中的字符串数组。 (所有的项目都是小写,所以情况不应该的问题。)

I'd like to know how I would find the index of an item in a string array. (All of the items are lowercase, so case shouldn't matter.)

推荐答案

这是一个静态的(共享)法阵类接受实际的数组作为第一个参数,如:

It's a static (Shared) method on the Array class that accepts the actual array as the first parameter, as:

Dim arrayofitems() As String
Dim itemindex As Int32 = Array.IndexOf(arrayofitems, "item test")
Dim itemname As String = arrayofitems(itemindex)

MSDN页面

这篇关于用的IndexOf在VB.NET String数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆