mardi 31 octobre 2017

change the values of list in c# based on the certain value

I have the below mentioned list result which contains the volume for Eastern Day Light time and i want have latestResult list volume data for Mountain Standard Time

Can anyone please suggest optimized code to update the list values

var result = new List<XYZ>();
var latestResult = new List<XYZ>();

for(j=1;j<latestResult.count;j++)
for (i= diffvol;i< result.count; i++)
{
   //Code to implement

}
}

  public class XYZ
{
  public Decimal? B1Volume { get; set; }
  public Decimal? B2Volume { get; set; }
  public Decimal? B3Volume { get; set; }
public Decimal? B4Volume { get; set; }
  public Decimal? B5Volume { get; set; }
  .............
  .............
 public Decimal? B24Volume { get; set; }
}

I am trying to assign the value based on the timezone difference, Let's assume the timezone difference is 3 hours, I am assigning diffvol variable to 3 in the code

If the diffvol is 3 in the first iteration the following values need to be assigned to the list items

latestResult[0].B1Volume =  result[0].B3Volume;
latestResult[0].B2Volume =  result[0].B4Volume; 
latestResult[0].B3Volume = result[0].B5Volume;
...............
.................
latestResult[0].B21Volume = result[0].B24Volume;





Aucun commentaire:

Enregistrer un commentaire