+ 5
What's the difference between ref and out in C# ?
C#
3 odpowiedzi
+ 5
rel is used to state that the parameter passed may be modified by the method. in is used to state that the parameter passed cannot be modified by the method.
Out is used to state that the parameter passed must be modified by the method.
+ 3
ref is
may be modified by method
out is
must be modified by method
in is
cannot be modified by the method.
+ 2
Variables passed by `ref` specifier need to be initialized before they can be used e.g. passing them to a method.
Variables passed by `out` specifier are not necessarily be initialized before they can be used e.g. passing them to a method.
https://www.dotnettricks.com/learn/csharp/difference-between-ref-and-out-parameters