Ref and Out C Sharp
Ref and Out C Sharp
PASS BY VALUE
5
PASS BY REFERENCE
abc
console.writeline(“value is: ” + a);
int value = 5; }
PassByRef(ref value);15
console.writeline(value);
}
PASS BY OUT
{ {
console.writeline(value); }
OUT KEYWORD
The out keyword is similar to the ref keyword and causes arguments to be
passed by reference.
The only difference between the two is that the out keyword does not
require the variables that are passed by reference to be initialized.
Both the called method and the calling method must explicitly use the out
keyword.