Dofactory.com
Dofactory.com

How to add values to an array in C#

Below are two ways to assign values to an array:


// using array initializer

int[] terms = { 1, 2, 3, 4, 5, 6, 7 };


// using a for loop

int[] terms = new int[400];
for (int i = 0; i < terms.count(); i++)
{
   terms[i] = value;
}


Jack Poorte
Jack Poorte
Last updated on Sep 30, 2023



Stay Inspired!
Join other developers and designers who have already signed up for our mailing list.
Terms     Privacy     Cookies       Do Not Sell       Licensing      
Made with    in Austin, Texas.  - vsn 44.0.0
© Data & Object Factory, LLC.