If we have two methods, one returns the variable by value, and the other by reference, which has the highest performance?
myObj.Method1(out var);
or
var = myObj.Method2();
I assume the first version is more efficient, but does this mean that you should always create methods that return values by reference? Or is there some reason to return variables by value?
Thank.
The difference in performance will be immeasurably small or nonexistent.
You mistakenly believe that the two versions have different semantics.For reference types, both methods will copy the link exactly once.
out , ., !
out
out, 2 .
, .
, , , . , .
() , .
(structs) , , out .
Source: https://habr.com/ru/post/1788859/More articles:Suggestions for pluggable database - c #Combining multiple databases - sqlСсылка на основной поток в С# - multithreadingCreate an application that determines if a sequence of numbers is sorted - language-agnosticWordpress jquery confliction with plugin - jqueryScript file script with notification of completion - shellHow to write PNG files in java using RGB pixel values from 0 to 1? - javaDifference between isEmpty and equals ("") - javaHow to pass a pointer to a javascript function using GWT JSNI? - javascriptWhat is the BlackBerry equivalent of the WebView component of Androids? - androidAll Articles