|So I'm quite comfortable with shallow and deep cloning for value and reference types but want to check how this plays out for an array of a value type.
I have a 2D array of double and since the array contains value types I think the Array.Clone method (whilst only guaranteeing shallow copies) will give a deep copy in this instance. Am I right?
Private _matrix as double(,)
Public Function CopyToArray() as Double(,)
Public Function Copy() As Matrix
Return New Matrix(Me.CopyToArray())
Public Sub New(ByVal array As Double(,))
Me._matrix = array
The constructor assumes that the user wants to assign the 2D array of double(,) they have already created to the new matrix instance and hence doesn't use Array.Clone (and since the array is a class and is therefore a reference type, ByVal essentially has no meaning in this context). Did I get that bit right?