函数重载 : 函数名相同,参数不同,返回值不做要求
class Program
{
static int MaxValue(params int[] array)
{
int max = array[0];
for (int i = 1; i < array.Length; i++)
{
if (array[i] > max)
{
max = array[i];
}
}
return max;
}
static double MaxValue(params double[] array)
{
double max = array[0];
for (int i = 1; i < array.Length; i++)
{
if (array[i] > max)
{
max = array[i];
}
}
return max;
}
static void Main(string[] args)
{
int ret=MaxValue(12,13,45);
double ret2 = MaxValue(12.4, 16.5, 16.9);
Console.WriteLine(ret);
Console.WriteLine(ret2);
}
}