I have code which I want to return each of those values to 1 dp:
static void Main(string[] args)
{
decimal[] engine = { 2, 2.5M, 2.6M, 3 };
engine = engine.Select(x => { x = Math.Round(x, 1); return x; }).ToArray();
foreach (var item in engine)
{
Console.WriteLine(item);
}
Console.ReadLine();
}
So it would output something like this in a console application:
2.0
2.5
2.6
3.0
But the problem is, it outputs:
2
2.5
2.6
3
How can I make it return whole numbers to 1dp?
See these links for more format strings:
http://msdn.microsoft.com/en-us/library/dwhawy9k.aspx
http://msdn.microsoft.com/en-us/library/0c899ak8.aspx