Hello
The script I have below does what I've been asked :
Write a method that accepts an array of numbers as a parameter. The method should multiply each number by ten, and display the results. Call this method, passing to it an array of any three integers.
What I'd like to know is if this is correct or if there is a better way to do this?
Thanks
M
The script I have below does what I've been asked :
Write a method that accepts an array of numbers as a parameter. The method should multiply each number by ten, and display the results. Call this method, passing to it an array of any three integers.
What I'd like to know is if this is correct or if there is a better way to do this?
Code:
using System; class Array { int int1; int int2; int int3; public Array(params int[] numbers) { int1 = numbers[0]; int2 = numbers[1]; int3 = numbers[2]; Console.WriteLine("Number 1: " + (int1 * 10)); Console.WriteLine("Number 2: " + (int2 * 10)); Console.WriteLine("Number 3: " + (int3 * 10)); } } public class ArrayNumbers { public static void Main() { Array myArray = new Array(23, 2, 10); } }
M
Comment