foreach(int i in 你的数组)if(数字==i){}

解决方案 »

  1.   

    switch(i)
    {
      case 1:
      case 2:
        ....}
      

  2.   

    foreach(int i in new int[]{1,2,3,4,5,6,7,8,9,0})
    {
        if(i % 2 == 0)
        {
            Console.WriteLine(i.ToString());
        }
    }
    Console.ReadLine();
      

  3.   

    可以考虑用集合的Contains 方法来代替in的这个用法
      

  4.   

    在 C C++ C# 都没有~
      

  5.   

    foreach(int i in 你的数组)if(数字==i){}
      

  6.   

    实际上思路是这样的:
    int yourNum = 5;
    foreach(int i in new int[]{1,2,3,4,5,6,7,8,9,0})
    {
        if(i == yourNum)
        {
            Console.WriteLine(i.ToString());
        }
    }
    Console.ReadLine();
      

  7.   

    int yourNum = 5;
    foreach(int i in new int[]{1,2,3,4,5,6,7,8,9,0})
    {
        if(i == yourNum)
        {
            Console.WriteLine(i.ToString());
        }
    }
    Console.ReadLine();
      

  8.   

    foreach(int i in 你的数组)
    {
    if(数字==i){}
    }
    这个比较相似