I am not quiet sure about the concept of "passing by value" and "passing by reference" in c#. I think Passing by value mean :
int i = 9;
we pass int i into a method like: method(i) Passing by reference means exactly passing its location like :
Class.method.variable
and it will give out the value. Can anybody help me out??
In simple terms...
"Passing by value" means that you pass the actual value of the variable into the function. So, in your example, it would pass the value 9.
"Passing by reference" means that you pass the variable itself into the function (not just the value). So, in your example, it would pass an integer object with the value of 9.
This has various consequences, and each is useful in different situations.
This answer has more thorough information: What's the difference between passing by reference vs. passing by value?
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