检查asp.net中字符串数组中的索引 [英] check index in string array in asp.net
本文介绍了检查asp.net中字符串数组中的索引的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个字符串数组
我想检查一下,如果数组中的索引存在或不是
for exp,我的数组可以是
ckh [0] =111
ckh [2] =222
或
I have a string array
and i want to check , if index in array exist or not
for exp, my array can be
ckh[0]="111"
ckh[2]="222"
or
ckh[1]="345"
ckh[2]="222"
i想检查字符串数组是否有0,1,2索引
i want to check if string array has 0 , 1 , 2 index or not
推荐答案
试试这个..
Try this..
string[] ckh = { "111", "222" };
string value = "111";
int index = ckh.ToList().IndexOf(value);
string [] arr = {"One","Two","Three"};
var target = "One";
var results = Array.FindAll(arr, s => s.Equals(target));
或
OR
string stringToCheck = "text1";
string[] stringArray = { "text1", "testtest", "test1test2", "test2text1" };
foreach (string x in stringArray)
{
if (x.Contains(stringToCheck))
{
// Process...
}
}
试一试。这可能有所帮助。如果不在这里问。
Give it a try.This may help.If not ask here.
检查此链接,可能这就是您要找的。
http: //stackoverflow.com/questions/16684609/how-to-check-the-condition-in-asp-net-for-string-array [ ^ ]
http://asp-net-example.blogspot.in/2009/01/how-to-get-string-array-specific-index.html [ ^ ]
^
Check this link, may be this is what you are looking for.
http://stackoverflow.com/questions/16684609/how-to-check-the-condition-in-asp-net-for-string-array[^]
http://asp-net-example.blogspot.in/2009/01/how-to-get-string-array-specific-index.html[^]
^
这篇关于检查asp.net中字符串数组中的索引的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文