If you take your variable decreturn
and do Math.Round(decreturn, 2)
or String.Format("{0:F2}", decreturn)
, it works as expected.
The following example is working:
using System;
public class Program
{
public static void Main()
{
Random RNG = new Random();
decimal divab50 = RNG.Next(50,100);
decimal divbl50 = RNG.Next(6,50);
decimal decreturn = divab50 / divbl50;
decimal rounded = Math.Round(decreturn, 2);
Console.WriteLine(rounded);
}
}
Fiddle to test with Math.Round
: https://dotnetfiddle.net/70LTrm
You could also apply String.Format
for this purpose like this:
using System;
public class Program
{
public static void Main()
{
Random RNG = new Random();
decimal divab50 = RNG.Next(50,100);
decimal divbl50 = RNG.Next(6,50);
decimal decreturn = divab50 / divbl50;
var rounded = String.Format("{0:F2}", decreturn);
Console.WriteLine(rounded);
}
}
Fiddle to test with String.Format
: https://dotnetfiddle.net/6Yy8uU
Take a look to the documentation of Math.Round
and String.Format
for more info.