CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Oct 2007
    Posts
    22

    Stupid Byte[] question

    Folks,

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

    Code:
    // 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.

  2. #2
    Join Date
    Jan 2002
    Location
    Scaro, UK
    Posts
    5,940

    Re: Stupid Byte[] question

    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.

    Code:
    void MyMethod(byte [] bytes, int offset, int count)
    {
    }
    Darwen.
    www.pinvoker.com - PInvoker - the .NET PInvoke Interface Exporter for C++ Dlls.

  3. #3
    Join Date
    Oct 2007
    Posts
    22

    Re: Stupid Byte[] question

    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!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured