zozo ahmed

zozo ahmed

  • NA
  • 18
  • 16k

search number in array of bit but not found in C#?

Oct 25 2013 8:36 AM
program in c# , (a array) of bytes contain data of mp4 file array , then convert array of 


bytes to array of bit,i want to search for "00000000000000000000000110110110" in  array  


bits and search  for "00000000000000000000000110110110" but not found ,what is wrong??




    byte[] a = new byte[100000]; //contain data of mp4 file I copy data to an array
             
    BitArray bits = new BitArray(a); // convert array of byte to array of bit


    BitArray bitss = new BitArray(32);  //create new array size 32 has value   {00000000000000000000000110110110}


       // false is default value


    bitss.Set(23,true);  // add 1 to array in location 23,24,26,27,29,30
    bitss.Set(24,true);
    bitss.Set(26,true);
    bitss.Set(27,true);
    bitss.Set(29,true);
    bitss.Set(30,true);


    int i=0;


    while( i< bits.Length)  //search for {00000000000000000000000110110110}
                            // in array bits
    {
       if ((bits[i] == bitss[0]
         && bits[i + 1] == bitss[1]
         && bits[i + 2] == bitss[2]
         && bits[i + 3] == bitss[3]
         && bits[i + 4] == bitss[4]
         && bits[i + 5] == bitss[5]
         && bits[i + 6] == bitss[6]
         && bits[i + 7] == bitss[7]
         && bits[i + 8] == bitss[8]
         && bits[i + 9] == bitss[9]
         && bits[i + 10] == bitss[10]
         && bits[i + 11] == bitss[11]
         && bits[i + 12] == bitss[12]
         && bits[i + 13] == bitss[13]
         && bits[i + 14] == bitss[14]
         && bits[i + 15] == bitss[15]
         && bits[i + 16] == bitss[16]
         && bits[i + 17] == bitss[17]
         && bits[i + 18] == bitss[18]
         && bits[i + 19] == bitss[19]
         && bits[i + 20] == bitss[20]
         && bits[i + 21] == bitss[21]
         && bits[i + 22] == bitss[22]
         && bits[i + 23] == bitss[23]
         && bits[i + 24] == bitss[24]
         && bits[i + 25] == bitss[25]
         && bits[i + 26] == bitss[26]
         && bits[i + 27] == bitss[27]
         && bits[i + 28] == bitss[28]
         && bits[i + 29] == bitss[29]
         && bits[i + 30] == bitss[30]
         && bits[i + 31] == bitss[31]))
          Console.WriteLine("found"); i += 32;
    }




output not return found ,it must return found what is wrong ??

Answers (3)