Choose Category
using System; using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; namespace ForgetCode { class TestOut { static public void FillArray(out int[] myArray) { // Initialize the array: myArray = new int[5] { 1, 2, 3, 4, 5 }; } static public void Main() { int[] myArray; // Initialization is not required // Pass the array using out: FillArray(out myArray); // Display the array elements: Console.WriteLine("Array elements are:"); for (int i = 0; i < myArray.Length; i++) Console.WriteLine(myArray[i]); } } }
Array elements are: 1 2 3 4 5