I don’t know how to explain my question, please accept it in example form:
I wrote a library in C# language which has a method as below:
public object GetValueAt(int idx) {
return arr[idx];
}
Then I use it in VB.Net, ofcourse there’s a diffirent in index based between C# and VB.Net. So if I call that method with idx = 6, how does CLR know object which I try to access (it having idx = 5 on C#)?
That’s just my example, and what about existed library in .Net?
If you call that method from VB with
idx = 6it will returnarr[6]treatingarras 0-based (i.e. the seventh element), because the code is written in C#. No automatic rebasing is applied, because you’re just calling a method from VB.I thought the VB compiler automatically adjusts array indexes when the array indexing expression itself is in VB, but that’s not the case here – it’s just a method call. EDIT: It looks like that doesn’t happen anyway, at least not always. The compiler makes allowances when creating arrays, but not indexing into them, apparently…
EDIT: That chimes in with the MSDN "Arrays In Visual Basic" page which shows an example and explains:
And from this blog post: