Difference between reference(ref) and out( passing parameter ) in C# | Sololearn: Learn to code for FREE!
Neuer Kurs! Jeder Programmierer sollte generative KI lernen!
Kostenlose Lektion ausprobieren
+ 1

Difference between reference(ref) and out( passing parameter ) in C#

13th Aug 2019, 1:01 AM
Rio Fairhall
Rio Fairhall - avatar
2 Antworten
+ 2
With ref parameters, you can pass data into a method as well.
13th Aug 2019, 2:58 AM
Sonic
Sonic - avatar
+ 1
ref tells the compiler that the object is initialized before entering the function, while out tells the compiler that the object will be initialized inside the function. So while ref is two-ways, out is out-only. https://stackoverflow.com/questions/388464/whats-the-difference-between-the-ref-and-out-keywords
13th Aug 2019, 3:09 AM
Vahid
Vahid - avatar