Answer the question
In order to leave comments, you need to log in
What is the best way to pass objects to a function - by reference or by value?
Good evening.
Recently, the thought came to me why structures are more effective than objects, because it is much easier to pass a reference to an object than to copy. I used to blame everything on the initialization of the object itself, but recently I saw a few comments that passing by value (cheap copying) is optimal in principle.
Tell me, where can I find a good explanation or, even better, a good set of benchmarks?
I myself do not have enough experience to write test cases.
UPD.
I asked the question crookedly and incorrectly.
stackoverflow.com/questions/270408/is-it-better-in...
stackoverflow.com/questions/2139224/how-to-pass-ob...
The links are correct questions and correct answers.
Answer the question
In order to leave comments, you need to log in
Actually, marklarius 's answer does show when it's okay to use structs in .NET .
Well, again small objects. Thank you, but there is not enough information yet.
nprogramming.wordpress.com/2010/06/01/c-performance-class-vs-struct/
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question