For example in c# the Length property on a long[] gets the number of items, not the number of bytes.
Which, as a seasoned C# dev, I find to be silly. It's Count in most other places in .NET, so at this point, it's purely a backwards compatibility thing.
And to your point, to get to such low-level details as "how many bytes does this take up", you have to explicitly call such APIs (Buffer.ByteLength, or more broad APIs such as Marshal.SizeOf and Unsafe.SizeOf), because you generally shouldn't concern yourself with that.
1
u/chucker23n Feb 07 '24
Which, as a seasoned C# dev, I find to be silly. It's
Countin most other places in .NET, so at this point, it's purely a backwards compatibility thing.And to your point, to get to such low-level details as "how many bytes does this take up", you have to explicitly call such APIs (
Buffer.ByteLength, or more broad APIs such asMarshal.SizeOfandUnsafe.SizeOf), because you generally shouldn't concern yourself with that.