class Dator
{
private:
TemplatedType* data;
public:
Data( TemplatedType t )
{
data = &t
}
void setData( TemplatedType t )
{
(*data) = t; //effects the entire program.
}
}
(that isn't a complete/correct class, but you get the idea.) So I was trying to do this in C#, and I can't get it to work.
class Dator
{
private Object data;
public Dator( ref Object obj )
{
data = obj;
}
public Object Data
{
get { return data; }
set { data = value; }
}
}
I can't get changes that are placed upon data to manifest themselfs in the rest of the program- basically what I want is this in the client code:
Dator d = new Data( myInt ); //myInt = 42
d.Data = 22;
System.Console.Write( myInt ); //prints 42 instead of 22.
Now, objects (classes) are supposedly reference types- but that doesn't seem to be the case here...