Here’s a code snippet demonstrating how to initialize int arrays in C# and display the contents of it using the for loop.
How to Initialize int array in C# ?
using System; namespace ACConsoleApp1 { class Program { static void Main(string[] args) { int[] inputArray = new int[4] { 3, 5, 2, 4 }; for(int i=0;i<4;i++) Console.WriteLine(inputArray[i]); Console.ReadLine(); } } }
Leave a Reply