1
Answer

passing parameters with out

Photo of anndy smaals

anndy smaals

6y
450
1
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)