110,567
社区成员
发帖
与我相关
我的任务
分享
string item = "1,2,3,4,5";
string[] array = item.Split( new char[] { ',' } );
string a = "1";
for( int i = 0; i < array.Length; i++ )
{
if( array[ i ].Equals( a ) )
{
Response.Write( "存在" );
break;
}
}
class test
{
static void Main()
{
string[] elements=new string[50];
elements[1]="aaa";
elements[2]="bbb";
elements[3]="sss";
string str=string.Join("",elements);
if(str.IndexOf("sss")>-1)
{
Console.WriteLine("存在");
}
else
{
Console.WriteLine("不存在");
}
}
}
string[] elements = new string[50];
if ( Array.IndexOf<string>( elements, "sss" ) != -1 )
{
//存在
//返回的值就是 "sss" 在数组中的下标
}
else
{
//不存在
}