// Collection of code snippets by Arne Vajhøj // (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) using System; namespace E { public class Program { public static decimal DKRound(decimal v) { return Math.Round(v * 2, MidpointRounding.AwayFromZero)/2; } public static decimal Change(decimal paid, decimal price) { return DKRound(paid - price); } public static void Main(string[] args) { Console.WriteLine("{0:0.00}", Change(100.00m, 1.25m)); Console.WriteLine("{0:0.00}", Change(100.00m, 1.30m)); } } }