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 .
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
‘int’ is a value type and so copies the value on assignment, as you have discovered.
You could use pointers in the traditional C/C++ sense by using an ‘unsafe’ block but then the pointers are only usable inside that block which limits its use. If instead you want to access the value outside of an ‘unsafe’ block then you need to convert to using a reference instead.
Something like this…