// 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 static class MyExtensions { public static int Percent(this int x, int total) { return 100 * x / total; } public static double Percent(this double x, double total) { return 100 * x / total; } } public class Program { public static void Main(string[] args) { Console.WriteLine(12.Percent(50)); Console.WriteLine(12.34.Percent(50.00)); } } }