Ok,consider this methodpublic int sum(int x, int y){ int z = x + y; return z; }are the x or y changed during the method process, the response is no for sure, we call those paramters input parametersNow, what if you want that x recives the sum of x+y so the x will be at the same time an input and also an output so it has to be marked as refpublic int sum(ref int x, int y) { int x = x + y; return x; }Now, what if the x value is known as input so we dont need to set it, then it will be considered only as an output valuepublic int sum(out int x, int y){ x = 20; x = x + y; return x; }
hi,
Out And Ref are same but the difference is using out parameter we need to assigne the value the variable.
using ref parameter without assgineing the value ref parameter will work
Hi,
What is mean by OUT Parameters,Ref Parameters in C#?
Thanks,
Narasima