c# change array size code example

Example 1: add size to array C#

Array.Resize(ref arrayName, arrayName.Length + 4);

Example 2: declare string array c# without size

List<string> myStringList = new List<string();
myStringList.Add("Test 1");
myStringList.Add("Test 2");

Example 3: use length to resize an array

let array = [11, 12, 13, 14, 15];  
console.log(array.length); // 5  

array.length = 3;  
console.log(array.length); // 3  
console.log(array); // [11,12,13]

array.length = 0;  
console.log(array.length); // 0  
console.log(array); // []

Tags:

Java Example