public static Fraction operator -(Fraction first, Fraction second) { Fraction result = new Fraction(); result.Numerator = (first.Numerator * second.denominator) - (second.Numerator * first.denominator); result.Denominator = first.Denominator * second.Denominator; return result; }
public static void Main() { Fraction fraction1 = new Fraction(22, 7); Fraction fraction2 = new Fraction(40, 4); Fraction result = fraction1 + fraction2; Console.WriteLine(result); result = fraction1 - fraction2; Console.WriteLine(result); }