'Out' keyword in methods parameter

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • [Yosi]

    'Out' keyword in methods parameter

    I have the following DLL function prototype:
    RW_DLL_API int ReadBDll(DWORD Address,DWORD NumOfUnits, BYTE * val);

    I use this function from C# application as following:

    [DllImport("RW_D LL.dll")]
    extern static int ReadBDll(UInt32 Add, UInt32 NumOfUnits, out byte [] Block);

    then I call this function :
    byte [] arrayB = new byte[5];
    int i = ReadBDll(0x2e, 5,out arrayB );
    after execution the function I got 'arrayB' = <undefined value> .. WHY?

    how can I do that sent array of bytes to function then got the arrayB values????

  • Bjorn Abelli

    #2
    Re: 'Out' keyword in methods parameter


    "[Yosi]" wrote...[color=blue]
    > I have the following DLL function prototype:
    > RW_DLL_API int ReadBDll(DWORD Address,DWORD NumOfUnits, BYTE * val);
    >
    > I use this function from C# application as following:
    >
    > [DllImport("RW_D LL.dll")]
    > extern static int ReadBDll(UInt32 Add, UInt32 NumOfUnits, out byte [][/color]
    Block);

    Are you sure that it should be the "out" keyword there?
    From the code that follows, it seems like you need to use the "ref" keyword
    instead?
    [color=blue]
    > then I call this function :
    > byte [] arrayB = new byte[5];
    > int i = ReadBDll(0x2e, 5,out arrayB );
    > after execution the function I got 'arrayB' = <undefined value> .. WHY?[/color]

    To give a correct answer to your question, we would really need to know what
    the function is supposed to do, and how...

    // Bjorn A


    Comment

    Working...