1) Call by ref should be assigned before using where as Call by Out not required to assign a value.
Key Differences Between Ref and Out in C#
- When a variable preceded by the ref keyword is passed to any method then the changes made to it inside the method reflects in its original value. When a variable passed to a method is preceded by out keyword the method returns it without using return keyword.
- The ref parameter should be initialized before it is passed to a method. On the other hand, the out parameter must be initialized inside the method it is passed to.
- While calling, declaring, or defining a method, ref parameter is explicitly declared as ref. On the other hand, while calling, declaring, or defining a method, out parameter is explicitly declared as out.
No comments:
Post a Comment