Could someone please help me with this. I'm trying to replace the Value with the same value but only with the first decimal. As you can see below i end up with the same result as I start with.
public class QoutaDataHolder
{
public double StartTime { get; set; }
public double EndTime { get; set; }
public double Value { get; set; }
public string QoutaRuleID { get; set; }
}
List<QoutaDataHolder> correctionQoutas
for (int i = 0; i < correctionQoutas.Count; i++)
{
if (correctionQoutas[i].Value % 1 != 0) //Value = 2.88888889
{
var trunkatedValue = Math.Truncate(correctionQoutas[i].Value*10); //28
double newValue = trunkatedValue/10; // Back to 2.88888889!?!?
correctionQoutas[i].Value = newValue; // Want to assign 2.8
}
}
EDIT: I don't want to round the value!