C# code - SNMP packet processing
First things first.  Your variable names are not very well thought out.  Even after I decode it, cnt or count?? does not describe what it does.  I think a better name would be currentIndex.

Second, C# standards say to use camelCasing for variable names.  I would also read up on var, it is a very useful keyword for cleaning up code.

Third, brush should be a constant, if you follow my suggestion on the change to recursion, it should be made a class constant.

I also don't like that cnt is incremented outside of the loop.

Now onto the main question.

Just seeing if ((packet[objectstart] &gt; 127) | (packet[objectstart]  &lt; 127)) twice in the same structure (one inside the other one) is a huge code smell to me, especially when it is the same code inside the second, as it is the first.  This looks like a good case for recursion, a method calling itself.

It would go something like this:

private string ProcessSegment(int[] obj, int currentIndex, int objectStart, dynamic[] packet)
{
     if ((packet[objectstart] != 127) || currentIndex &gt; Objectlength)
     {
         return string.Empty;
     }

     Console.WriteLine(packet[objectstart]);

     var bin2 = packet[objectstart] &amp; brush;
     binR1 = Convert.ToString(bin2, 2).PadLeft(7, '0');

     obj[currentIndex] = Convert.ToInt16(packet[objectstart]);

     return binR1 + ProcessSegment(obj, currentIndex++, objectStart++, packet);
}


Your calling code will look something like:

obj[cnt] = Convert.ToInt16(packet[objectstart]);
objectstart++;

if (obj[cnt] &gt;127)
{
    result += ProcessSegment(obj, cnt++, objectstart++, packet);
}


I have no way of testing this, but I think it should work.  Also note, please change the dynamic in the ProcessSegment call to be whatever the packet variable is