vendredi 4 juillet 2014

How to get reference type of array of primitives?


Vote count:

0




So my question can be described by simply code:



double[] doubles = new double[] { 0.01, 0.01, };
var w2 = doubles;
doubles = null;
//w2 still has values


I know about difference between structs and classes:



If we copy the objects to new variables: Point p2 = p1; Form f2 = f1; p2, being a struct, becomes an independent copy of p1, with its own separate fields. But in the case of f2, all we’ve copied is a reference, with the result that both f1 and f2 point to the same object.



but is there any way of getting referenced type? Without using casting to List<double>, unsafe{}?



asked 25 secs ago






Aucun commentaire:

Enregistrer un commentaire