cannot convert from 'byte[]' to 'byte*'

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • efdeugenio
    New Member
    • Jul 2008
    • 2

    cannot convert from 'byte[]' to 'byte*'

    Hi, I will really appreciate if someone cans help me with this:

    I have a managed c++ class that I am calling from C#. The declaration of a function in this class is:
    bool CanAddTemplate( unsigned char* template, HRESULT rc, bool bInteractive)

    When calling this function from c# I have:

    byte[] template = new Byte[1632];

    bresult = CIdentification Set.CanAddTempl ate(template, rc, true);

    When compiling I am getting the error:

    Argument 1: cannot convert from 'byte[]' to 'byte*'

    What is the right type of data in c#?

    Thanks!
  • Plater
    Recognized Expert Expert
    • Apr 2007
    • 7872

    #2
    Well there's not really a direct transition from pointers (char*) to managed code I don't think.
    But I would try a string. Although it says it's a byte, which is wierd.
    Maybe there is something you can do with Marshalling

    Comment

    • r035198x
      MVP
      • Sep 2006
      • 13225

      #3
      You can use pointers in C#. Just mark the block that uses them as unsafe and create the pointers.

      Comment

      • efdeugenio
        New Member
        • Jul 2008
        • 2

        #4
        Thank you very much!

        Comment

        Working...