for example:
int x = 1;
int y = x;
y = 3;
Debug.WriteLine(x.ToString());
Is it any reference operator instead of "=" on line:3, to make the x equal to 3 , if i assign y =3 .
I once wrote a prototype of a version of C# that had that feature; you could say:
int x = 123;
ref int y = ref x;
and now x and y would be aliases for the same variable.
We decided to not add the feature to the language; if you have a really awesome usage case I'd love to hear it.
You're not the first person to ask about this feature; see Can I use a reference inside a C# function like C++? for more details.
UPDATE: The feature will likely be in C# 7.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With