anndy smaals

anndy smaals

  • NA
  • 24
  • 4.3k

passing parameters with out

Dec 15 2018 7:29 PM
write the method GetTopThree, which takes an array of integers and three integers as out int parameters. Assign the highest value in the array to the last out int parameter, the second highest to the second and the third highest to the first parameter.
 
using System;

namespace HelloWorld
{
class Program
{

static void Main(string[] args)
{
int bronze, silver, gold;

int[] numbers = { 100, 23, 3, 45, 6, 78 };

GetTopThree(numbers, out bronze, out silver, out gold);

Console.WriteLine(bronze + ", " + silver + ", " + gold);
}
}

Answers (1)