例如string a="A";
string[] F={"A","B","C"};
if(怎么判断a是否在数组F里)
{
在F里
}ELSE{不在}

解决方案 »

  1.   

    string a = "A";
    string[] F = { "A", "B", "C" };
    if (Array.IndexOf(F, a) >= 0)
    Response.Write("存在!");
    else
    Response.Write("不存在!");
      

  2.   

    。。有Contains方法判断 是否包含
    你也可以通过循环来判断!!!
      

  3.   

      string[] strs = new string[] { "a","b"};
      string a="a";
      bool isContains= (from c in strs where c==a   select 1).ToList().Count>0;LINQ 写法
      

  4.   

    for(int i=0;i<F.Length;i++)
    {
    if(a==F[i])
    {
    //存在
    }
    else
    {
    //不存在
    }
    }
      

  5.   

    for(int i=0;i<F.Length-1;i++)
    {
    if(a==F[i])
    {
    //存在
    }
    else
    {
    //不存在
    }
    }
    不好意思,写错啦上面
      

  6.   

    这么弱智的问题你也问............string a="A";
    string[] F={"A","B","C"};
    for(int i = 0 ; i < F.Length ; i++)
    {
       if(a.equels(F[i]))
         {
             //存在,你想做什么呢?
         }
        else
         {
             //不存在,你又想做什么呢???
         }
    }
      

  7.   

    参考使用Contains()方法来实现,代码简单明了。http://www.cnblogs.com/insus/archive/2011/12/16/2290093.html