Hi Danielb,
It can not be that simple :-)
You can not do copy object of any type!
Only classe that implements IClonable interface supports
object cloning.
You can provide something like "read-only" by:
public readonly int y = 5;
but it works with value types (structs) only.
And you can safely get value type variable by
the property e.g.:
private int intVal=4;
public int CopyOfIntVal {
get {
return intVal;
}
}
....but it wont work with classes.
If you want to make an object "read-only" you've
got to provide its "lock".
If you've got more questions then don't afraid of feedback.
Cheers!
Marcin
I need to create a read-only copy of Object X at run time, I know how
to find the type of Object X (using GetType) but how do I go about
creating a readonly copy of X?
What I want to do is this:
System.Type ValueType = Value.GetType() ;
create readonly object of type ValuteType and copy Value into it.
Cheers,
DanielB