From 545bc975a71f8be4a8f3a92bfe476bccbbdfa7b3 Mon Sep 17 00:00:00 2001 From: Stuart Mosquera Date: Mon, 9 Feb 2026 23:22:22 -0300 Subject: [PATCH] Update arrays.md --- content/c-sharp/concepts/arrays/arrays.md | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/content/c-sharp/concepts/arrays/arrays.md b/content/c-sharp/concepts/arrays/arrays.md index d0f3f96b3db..c900f023185 100644 --- a/content/c-sharp/concepts/arrays/arrays.md +++ b/content/c-sharp/concepts/arrays/arrays.md @@ -24,11 +24,21 @@ type[] arrayName; // Create the array variable and initialize it with an array of N items: type[] arrayName = new type[N]; +// Classic Syntax + // Create the array variable and initialize it by specifying the contents: type[] arrayName = new type[] { value1, value2, value3, ... valueN }; // Alternative way of creating the array and specifying the contents: type[] arrayName = { value1, value2, value3, ... valueN }; + +// Collection Expression Syntax (C# 12+) + +// Create an empty array: +type[] arrayName = []; + +// Create the array variable and initialize it by specifying the contents: +type[] arrayName = [ value1, value2, value3, ... valueN ] ``` > **Note:** Arrays in C# have a set size, meaning the number of elements they hold cannot be changed once the array has been created. @@ -44,8 +54,8 @@ public class Example { public static void Main(string[] args) { - char[] vowels = {'a', 'e', 'i', 'o', 'u'}; - // indexes: 0 1 2 3 4 + char[] vowels = [ 'a', 'e', 'i', 'o', 'u' ]; + // indexes: 0 1 2 3 4 Console.WriteLine(vowels[0]); // Output: a