When formal args are modified and if modifications are REFLECTED on actual
args then this concepts is called as Pass by reference.
When formal args are modified and if modifications are not REFLECTED on
actual args then the concepts is called as Pass by value.
By default all the variables will be pass by value.
ref is a keyword, which is required while passing a variable by reference.
ref keyword must be used along with actual and formal args.
ref variables must be initialized before passing.
Form1 code :
public partial class Form1 : Form
public void print(ref int x, int y)//formal args
int z = x;
x = y;
y = z;
private void button1_Click(object sender, EventArgs e)
int a = 10, b = 20;
vikasnigam v = new vikasnigam();
v.print(ref a, b);//actual args.