Saturday, April 30, 2011

Difference between call by out and call by reference

out = ref -  (intiliazation)

void main()
{

int x,y,o,r;

//ref
r=0;
MultiMath(x,y,ref r);
MultiMath(x,y,out o);

}



functions

OUT
private int MultiMath(int a, int b, out o)
{
    o = a*b;
return a+b;
}

REF
private int MultiMath(int a, int b, out r)
{
    r = a*b;
return a+b;
}

http://www.c-sharpcorner.com/UploadFile/5eae74/6867/

No comments:

Post a Comment