Compare two decimal value using method - CSharp Language Basics

CSharp examples for Language Basics:decimal

Description

Compare two decimal value using method

Demo Code

using System;/*  w ww.j  a  v a 2  s  . c o m*/
class MaxSales
{
   public static void Main()
   {
      decimal [] person1Sales = {40, 10, 25, 5, 33, 6};
      decimal [] person2Sales = {80, 30, 11, 4, 33, 5};
      for (int i = 0; i < 6; i++)
      {
         Console.WriteLine("Month {0}: {1,11:C}", i+1, MaxAmount(person1Sales[i], person2Sales[i]));
      }
   }
   private static decimal MaxAmount(decimal a, decimal b)
   {
      if (a > b)
         return a;
      else
         return b;
   }
}

Result


Related Tutorials