I'm sorry if this has been asked before, but I don't even know what to search for to find an answer.
I'm fairly experienced in .net/c# etc., however, I have come across something I don't understand how works.
I'm working on a third party library where I do not have access to the source.
My question is: How is this function able to get the whole data in the array when only the first value is being passed?
Prototype:
SomeClass(ref byte pByte, int length);
Code example:
...
byte[] bArr = new byte[100];
// fill array with some data
SomeClass(ref bArr[0], bArr.Length);
...
Update: Sorry I didn't include this in the post to begin with. I am en experienced embedded fw engineer but I have also worked with c#/.net/wpf/wcf etc. for many years. So I am well aware of the difference between pass-by-value/reference and the ref modifier. My initial confusion was that I have never seen any c# function calls only passing the first element in an array (like pointers in c/c++) and the function can access the whole array. So it's more the syntax that got me. :)
Thanks to @jdweng's comment I used iLSpy to confirm Nicholas Carey's answer. The library is just a CLR wrapped c++ library where the dll importing and marshaling is done.
Thank you all for your answers. :)
byte[] bytesis also a reference. What the ref variable introduces is the ability to make the reference point to a different object.