If you have a Bitmap object that needs to be passed to numerous methods (about 10), and finally to an event where it shall finally be disposed of after it's used, would it be (performance wise) beneficial to pass it to every one of those methods by reference instead of value?
Passing by value, the object is copied, passing by reference its not.
(Performance is critical in this situation. The application needs to run as fast as possible.)
Bitmap is a reference type. Passing a reference type by value does not copy the object, merely the reference to the object. There would be no performance benefit to passing the Bitmap by reference instead of by value.
Since Bitmap is a reference type, there is no practical difference for performance in this scenario as it is already being passed by reference to the method.
I'd recommend Jon Skeet's article on the subject for a thorough explanation of how "by reference" and "by value" work in C#.
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