Um...there are a couple of oddities there.
startIndex
doesn't sound like a pointer - it sounds like an integer which indexes into a memory structure of some form: an array or similar.
You are also converting a Length to a pointer which is going to be odd.
But when you get to your code that shows the error:
if ((chPtr + length) <= chPtr2))
What you are telling the compiler to do is add
chPtr
to
length
: and they are both declared as pointers:
char* length = (char*) value.Length;
char* chPtr = (char*) startIndex;
Which means you are telling the compiler to add two pointers - which doesn't produce anything useful, but certainly doesn't produce another pointer. Think of it in terms of DateTime: if you subtract two DateTime values, you get a Timespan - the difference between the two dates. If you subtract two pointers, you get in integer (or long) - the number of bytes between the two pointer values. But if you add two DateTimes, what do you get? Nothing useful. The same applies to pointers - adding them doesn't produce anything useful!
I don't think any of those three values should be pointers at all!