W
wxdeveloper
Hello,
I am a C++ developer converting to C# but I am still thinking in C++
way![Smile :) :)](/styles/default/custom/smilies/smile.gif)
In C++ I can do this:
double* p1 = new double;
double* p2 = p1;
*p1 = 5.0;
*p2 = 7.0;
Now both *p1 and *p2 have value 7 (they are pointing the same address
in memory).
Now I would like to achieve the same thing in C# (I would like to have
a reference to double) but if I do this:
System.Double a = new System.Double();
System.Double b = a;
a = 5;
b = 7;
It will not work. I understand that his because double is a value type
and it cannot be used as a reference no matter what (System.Double is
value type).
So far the only other way to go around this problem is to use a class
with double value inside than I can create as many references to the
object as I need.
Is my thinking correct ?
Thank you
J. Grabis
I am a C++ developer converting to C# but I am still thinking in C++
way
![Smile :) :)](/styles/default/custom/smilies/smile.gif)
In C++ I can do this:
double* p1 = new double;
double* p2 = p1;
*p1 = 5.0;
*p2 = 7.0;
Now both *p1 and *p2 have value 7 (they are pointing the same address
in memory).
Now I would like to achieve the same thing in C# (I would like to have
a reference to double) but if I do this:
System.Double a = new System.Double();
System.Double b = a;
a = 5;
b = 7;
It will not work. I understand that his because double is a value type
and it cannot be used as a reference no matter what (System.Double is
value type).
So far the only other way to go around this problem is to use a class
with double value inside than I can create as many references to the
object as I need.
Is my thinking correct ?
Thank you
J. Grabis