This question is already an answer here
- 7 answers
I have an array Passing items which I have insulated but no matter what is being changed in I try the original array for some reason. Personal DSPPositionPeriodDO [] CompactShortTermData (DSPPositionPeriodDO [] data) {DSPPositionPeriodDO [] resultArray = (DSPPositionPeriodDO []) data. Clone (); Int? HoursToAggBy = Null; // This is a short term, the data gets too high so how many / var days = (_endDate - _startDate). Total days; If (day & lieutenne; = 3) hours then ifgab = null; Otherwise if (day> 3 & amp; nbsp; day & lt; = 7) hours toAggBy = 1; Otherwise if (day> 7th & amp; day & lt; = 14) hours sogeby = 2; And if (day> 14 & amp; nbsp; days & lt; = 21) hours toAggBy = 3; And if (day> 21) hours are thereby = 4; If (hours tiegaby! = Null) {// round-down time forfora (paragraph parody in error as a result) {var sl = posPeriod.StartLocal; Sl = sl.AddHours (- (sl.Hour% hoursToAggBy.Value)); Sl = sl.AddMinutes (-sl.Minute); PosPeriod.StartLocal = sl; } // group by unit & amp; Time - get average groupedData = resultArray.GroupBy (X => New {x.EntityId, x.EntityCode, x.StartLocal}). Selection (Ch => New DSPPositionPeriodDO {EntityId = g.Key.EntityId, EntityCode = g.Key.EntityCode, StartLocal = g.Key.StartLocal, volume = g.Average (v => v.Volume), AverageVolume = null}); ResultsArray = Grouped DataOor (); }
I have tried to create a separate copy such as:
var x = root. ToArray () .. toList () ... clone ...
etc.
By default I'm passing in the object of the data I do not want to change it at all.
From:
The reference to the new array point is the same as the original objects Reference in the array point.
You must clone the each object in a new array.
No comments:
Post a Comment