When we pass a parameter as ref to a method, the method refers to the same variable and changes made will affect
the actual variable. even the variable passed as out parameter is same as ref parameter, but implementation in c# is different,
Arguement passed as ref parameter must be initialized before it is passed to the method. But in case of out
parameter it is not necessary. But after a call to a method as out parameter it is necessary to initialize.
When to use out and ref parameter, out parameter is used when we want to return more than one value from a method.
Join MindStick Community
You need to log in or register to vote on answers or questions.
We use cookies to ensure you have the best browsing experience on our website. By using our site, you
acknowledge that you have read and understood our
Cookie Policy &
Privacy Policy.
When we pass a parameter as ref to a method, the method refers to the same variable and changes made will affect the actual variable. even the variable passed as out parameter is same as ref parameter, but implementation in c# is different,
Arguement passed as ref parameter must be initialized before it is passed to the method. But in case of out parameter it is not necessary. But after a call to a method as out parameter it is necessary to initialize.
When to use out and ref parameter, out parameter is used when we want to return more than one value from a method.