I am converting a file into byte array (16 to keep it simple) and would like to exit the loop after repetitive even occurs.
For example for a set of 24,2,16,21,0,0,0,0,9,12,52,50,0,0,1: output of the program should read 24,2,16,21,4-0 while ignoring the rest of the data for next loop
In my current code (Shown below) I am not just don't know how to exit the loop but even getting output as 24,2,16,21,1-0 2-0 3-0. Please guide
using (Stream video = File.OpenRead(@"C:\---------------------"))
{ byte[] buffer = new byte[16]; int bytesRead = video.Read(buffer, 0, buffer.Length); int c = 1; for (int p = 0; p < 16; p++) //block { if (buffer[p] == buffer[p + 1]) { Console.WriteLine(c + "-" + buffer[p]); } else { Console.WriteLine(buffer[p] + "," ); }
}