This questions stems from the MSDN page on LinkedList under "Remarks" (fifth line).
Lists that contain reference types perform better when a node and its value are created at the same time. LinkedList accepts null as a valid Value property for reference types and allows duplicate values.
I have searched through the source code and nothing really stands out to me. Could it be that this line was once true but was just forgotten about? If not, then why is it the case?
My guess is that it has to do with Locality of reference.
.NET uses a compressing garbage collector, that means that in case of reference type values, those would be allocated alongside its related LinkedListNode<T>
in the actual RAM region. If you access the value right after reaching the node, there is a good chance the value is already in cache.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With