W
WayneD
Hi All,
Just got started in C#...
Here's some C# code:
public MyClass
{
private MyThingy m_Thingy;
public SetThingy(MyThingy thingy)
{
m_Thingy = thingy;
}
}
I just found out that MyClass.m_Thingy will actually be referencing the same
MyThingy object that the caller passed in. Similar code in C++ would have
invoked the implied = operator and just copied the contents giving me a
separate, independent object with values initialized to what the passed in
object has. This is what I need, but I don't know how to make C# do the
same. How is this accomplished in C#?? I could always write a Copy
Constructor for MyThingy and do m_Thingy = new MyThingy(thingy) but I was
hoping there was another way so I don't have to write the copy constructor
in cases like this.
Thanks for any help,
Wayne
Just got started in C#...
Here's some C# code:
public MyClass
{
private MyThingy m_Thingy;
public SetThingy(MyThingy thingy)
{
m_Thingy = thingy;
}
}
I just found out that MyClass.m_Thingy will actually be referencing the same
MyThingy object that the caller passed in. Similar code in C++ would have
invoked the implied = operator and just copied the contents giving me a
separate, independent object with values initialized to what the passed in
object has. This is what I need, but I don't know how to make C# do the
same. How is this accomplished in C#?? I could always write a Copy
Constructor for MyThingy and do m_Thingy = new MyThingy(thingy) but I was
hoping there was another way so I don't have to write the copy constructor
in cases like this.
Thanks for any help,
Wayne