private static int FindNullTerminator(byte[] buffer, int pos) { int termPos = pos; while (termPos < buffer.Length && buffer[termPos] != '\0') termPos++; return termPos; } }