Initializing Arrays
This lesson covers initializing static, dynamic and implicitly typed arrays.
Initializing Static Arrays
An array can be declared and filled with the default value using square bracket ([]
) initialization syntax.
For
example, creating and initializing an array of 5 integers:
Press + to interact
using System;public class MainClass {public static void Main(String [] args){int[] arr = { 24, 2, 13, 47, 45 };foreach(var item in arr){Console.WriteLine(item.ToString());}}}
Exampl
...Get hands-on with 1400+ tech skills courses.