请教关于数组查询的问题
现有两个数组,如何通过查询其中一个数组,得到匹配的字符之后,相应得将另外一个数组中的字符输出?希望能得到源代码实例,谢谢了! --------------------编程问答--------------------string[] cateID ={ "1","2","3","4","5"};--------------------编程问答--------------------
string[] cateName ={ "1.A", "1.B", "1.C", "1.D", "1.E" };
for (int i = 0; i < cateID.Length; i++)
{
if (cateID[i] == "你传入的值")
{
Response.Write(cateName[i]);
}
}
--------------------编程问答-------------------- 看你向查什么,想输出什么,记录值用中间变量 --------------------编程问答-------------------- 1.Regex
/// <summary>
///
/// </summary>
/// <param name="arry1"></param>
/// <param name="arry2"></param>
/// <param name="c">要查找的字符</param>
/// <returns></returns>
public string getChar(string[] arry1, string arry2,char c)
{
string reVal = string.Empty;
if (arry1.ToString().IndexOf(c) != -1)
{
for (int i = 0; i < arry2.Length; i++)
{
if ((char)arry2[i] == c)
{
reVal += arry2[i];
}
}
}
return reVal;
}
2.Array.FindAll --------------------编程问答--------------------
string[] cateID ={ "1","2","3","4","5"};--------------------编程问答-------------------- -_-!!! Array.FindAll .. --------------------编程问答-------------------- 楼上的,什么意思,很奇怪吗? --------------------编程问答-------------------- To: SassyBoy ..
string[] cateName ={ ..... };
for (int i = 0; i < cateID.Length; i++)
{
if (Array.IndexOf(cateName,cateID[i])>-1)
{
Response.Write(cateName[i]);
}
}
^ō^ 你误会了, 我是汗LZ, 表达不清.. --------------------编程问答-------------------- o~hoho --------------------编程问答-------------------- -_-!
补充:.NET技术 , C#