On Tue, 06 Sep 2011 05:28:22 -0400, malio <[email protected]>
wrote:
Hi guys,
I'm a bit confused what exactly ref means and in which cases I
definitely need this keyword.
ref is simple. It's a pointer, but without the messy pointer syntax.
These two programs are exactly the same (will generate the same code):
void foo(int *i)
{
*i = 5;
}
void main()
{
int x = 2;
foo(&x);
}
----------------------
void foo(ref int i)
{
i = 5;
}
void main()
{
int x = 2;
foo(x); // note, there's no need to use &, the compiler does it for you
}
-Steve