Click to See Complete Forum and Search --> : Stupid Byte[] question


sb101
September 30th, 2008, 10:05 AM
Folks,

is there a way to pass a Byte[] to a function starting at a specific offset. For exmaple:


// c code
void func(unsigned char *arrayPtr) {
}

unsigned char test[100];
func(&test[50]);


So I want to pass a byte array but at an offset (in this case 50).

Thanks.

darwen
September 30th, 2008, 10:16 AM
No, there's not. At least, not using verifyable (not 'unsafe') .NET code - which is what you should be aiming for.

The way the framework usually does this is to pass an offset & length into any method which accepts a byte [] array.

e.g.


void MyMethod(byte [] bytes, int offset, int count)
{
}


Darwen.

sb101
September 30th, 2008, 10:28 AM
Thanks, that's how I've implemented the code at the moment (offset & size params). I just wanted to make sure I wasn't missing an easy Byte function that provided the functionality I required.

Thanks again!