As far as I know, object variables point to/reference the beginning of their respective object addresses.
class Foo
{
int a;
int b;
}
Foo foo = new Foo();
In the above code, foo
would point to an instance of Foo
created by using new
operator, and if the address of that instance was at 0x0010, the address of field a
(or maybe b
) would also be 0x0010. Similarly, if I created an array of integers and the array object was created at 0x0020, the element at index 0 would share the same address (the indexes are just offsets, right?). However, after reading this article (https://learn.microsoft.com/en-us/archive/msdn-magazine/2005/may/net-framework-internals-how-the-clr-creates-runtime-objects#S7), it seems that, at least in C#, 4 bytes are allocated for TypeHandle at the beginning of every object. If true, then does the first element of every array really start at object address + 4?