REF: - In the ref parameter, we pass the parameter by using ‘ref’ keyword. When we pass any ref parameter then we have to assign value in that variable those we have to pass. Without assigning we cannot pass the parameter.
Syntax: - method name(ref value type variable name);
OUT: - In the out parameter, we pass the parameter by using ‘out’ keyword. When we pass any out parameter then we don’t have assign value in that variable those we have to pass.
Syntax: - method name(out value type variable name);
Example: -"OUT"
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BreakAndContinue
{
class Program
{
public static void Add(out int a)
{
a = 50;
Console.WriteLine(a);
}
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.
REF: - In the ref parameter, we pass the parameter by using ‘ref’ keyword. When we pass any ref parameter then we have to assign value in that variable those we have to pass. Without assigning we cannot pass the parameter.
Syntax: - method name(ref value type variable name);
OUT: - In the out parameter, we pass the parameter by using ‘out’ keyword. When we pass any out parameter then we don’t have assign value in that variable those we have to pass.
Syntax: - method name(out value type variable name);
Example: -"OUT"
Example: -"ref"