How deep should a deep copy go? / Is an object that contains value type still a reference type?
- From: ahaupt@xxxxxxxxx
- Date: 30 Aug 2005 05:32:47 -0700
Hi all,
I'm implementing the Clone() method through the ICloneable interface
and don't quite know how deep I need to go for a deep copy.
Example:
class A: ICloneable
{
object _val;
//Val will always be a value type
A(object val)
{
_val = val;
}
object Clone()
{
//Don't know if I this is sufficient
return new A(_val);
//Or do I have to go
object newVal;
if(val.GetType() == typeof(bool))
{
newVal = (bool) val;
}
//....etc....//
return new A(newVal)
}
}
Thus do I have to cast the object back to a value type before returning
the cloned instance.
So I suppose the real question is: Is an object that contains value
type still a reference type?
Thanks,
Andre
.
- Follow-Ups:
- Re: How deep should a deep copy go? / Is an object that contains value type still a reference type?
- From: Lasse Vågsæther Karlsen
- Re: How deep should a deep copy go? / Is an object that contains value type still a reference type?
- From: shiv_koirala
- Re: How deep should a deep copy go? / Is an object that contains value type still a reference type?
- From: ahaupt
- Re: How deep should a deep copy go? / Is an object that contains value type still a reference type?
- Prev by Date: BUG in non-blocking socket connect ?
- Next by Date: list of domains
- Previous by thread: BUG in non-blocking socket connect ?
- Next by thread: Re: How deep should a deep copy go? / Is an object that contains value type still a reference type?
- Index(es):
Relevant Pages
|