I have a function to return minimum of n numbers. Code given below:
=====[ CODE ]=============== =============== =
private int FindMinimum(int[] numbers)
{
int temp, i;
temp = 0;
for (i=0; i<= numbers.length; i++)
{
temp = Math.Min(temp, numbers[i]);
}
return temp;
}
=============== =============== ============
I have not checked the above code. I actually want that the return
type be generic, so that I can use this function for int, double or
decimal. How to modify the above function to use generic return type?
=====[ CODE ]=============== =============== =
private int FindMinimum(int[] numbers)
{
int temp, i;
temp = 0;
for (i=0; i<= numbers.length; i++)
{
temp = Math.Min(temp, numbers[i]);
}
return temp;
}
=============== =============== ============
I have not checked the above code. I actually want that the return
type be generic, so that I can use this function for int, double or
decimal. How to modify the above function to use generic return type?
Comment