foreach (Byte bajt in data ) {
                    BufferIndex = i++;
                    if (!char.IsControl((char)bajt))
                        MyCharacter = Convert.ToChar(bajt).ToString();//Encoding.ASCII.GetString(new[]{bajt});
                    else
                        MyCharacter = " ";

                    if (BufferIndex == 200)
                        {
                            int a = BufferIndex;
                        }

                    
                    if (BufferIndex < 200)
                    {
                        sw.WriteLine("PrintBuffer1[" + BufferIndex + "] :=\t" + bajt + "\t; // " + String.Format(@"0x{0:x2}", (ushort)bajt) + "\t" + MyCharacter );
                    }

                    if (BufferIndex >= 200 && BufferIndex  < 400)
                    {
                        BufferIndex = BufferIndex - 200;
                        sw.WriteLine("PrintBuffer2[" + BufferIndex + "] :=" + bajt + "; // " + String.Format(@"0x{0:x2}", (ushort)bajt) + "   " + MyCharacter);
                    }
                    if (BufferIndex >= 400 && BufferIndex < 600)
                    {
                        BufferIndex = BufferIndex - 400;
                        sw.WriteLine("PrintBuffer3[" + BufferIndex + "] :=" + bajt + "; // " + String.Format(@"0x{0:x2}", (ushort)bajt) + "   " + MyCharacter);
                    }
                    if (BufferIndex >= 600 && BufferIndex < 800)
                    {
                        BufferIndex = BufferIndex - 600;
                        sw.WriteLine("PrintBuffer4[" + BufferIndex + "] :=" + bajt + "; // " + String.Format(@"0x{0:x2}", (ushort)bajt) + "   " + MyCharacter);
                    }
                    if (BufferIndex >= 800 && BufferIndex < 1000)
                    {
                        BufferIndex = BufferIndex - 800;
                        sw.WriteLine("PrintBuffer5[" + BufferIndex + "] :=" + bajt + "; // " + String.Format(@"0x{0:x2}", (ushort)bajt) + "   " + MyCharacter);
                    }
                    if (BufferIndex >= 1000 && BufferIndex < 1200)
                    {
                        BufferIndex = BufferIndex - 1000;
                        sw.WriteLine("PrintBuffer6[" + BufferIndex + "] :=" + bajt + "; // " + String.Format(@"0x{0:x2}", (ushort)bajt) + "   " + MyCharacter);
                    }
                    if (BufferIndex >= 1200 && BufferIndex < 1400)
                    {
	                        BufferIndex = BufferIndex - 1200;
                        sw.WriteLine("PrintBuffer7[" + BufferIndex + "] :=" + bajt + "; // " + String.Format(@"0x{0:x2}", (ushort)bajt) + "   " + MyCharacter);
                    }
                    if (BufferIndex >= 1400 && BufferIndex < 1600)
                    {
                        BufferIndex = BufferIndex - 1400;
                        sw.WriteLine("PrintBuffer8[" + BufferIndex + "] :=" + bajt + "; // " + String.Format(@"0x{0:x2}", (ushort)bajt) + "   " + MyCharacter);
                    }
                    if (BufferIndex >= 1600 && BufferIndex < 1800)
                    {
                        BufferIndex = BufferIndex - 1600;
                        sw.WriteLine("PrintBuffer9[" + BufferIndex + "] :=" + bajt + "; // " + String.Format(@"0x{0:x2}", (ushort)bajt) + "   " + MyCharacter);
                    }
                    if (BufferIndex >= 1800 && BufferIndex < 2000)
                    {
                        BufferIndex = BufferIndex - 1800;
                        sw.WriteLine("PrintBuffer10[" + BufferIndex + "] :=" + bajt + "; // " + String.Format(@"0x{0:x2}", (ushort)bajt) + "   " + MyCharacter);
                    }
                    if (BufferIndex >= 2000 && BufferIndex < 2200)
                    {
                        BufferIndex = BufferIndex - 2000;
                        sw.WriteLine("PrintBuffer11[" + BufferIndex + "] :=" + bajt + "; // " + String.Format(@"0x{0:x2}", (ushort)bajt) + "   " + MyCharacter);
                    }
                    if (BufferIndex >= 2200 && BufferIndex < 2400)
                    {
                        BufferIndex = BufferIndex - 2200;
                        sw.WriteLine("PrintBuffer12[" + BufferIndex + "] :=" + bajt + "; // " + String.Format(@"0x{0:x2}", (ushort)bajt) + "   " + MyCharacter);
                    }

                        
                }

don't repeat yourself.. whyy we don't have PrintBufeer[i] ?

By Anonymous, 2016-02-08 09:52:40