February 2009

February 8, 2009

C# Arrays Tutorial 1

1) .NET arrays are zero-based, meaning the first element of the array is at subscript-0
2) Use square brackets after the type on the left side of the equal sign to indicate an array
3) Use square brackets - and usually a number - on the right side of the equal sign to set the size of the fixed array
4) To loop through the array use either:
a) “foreach” loop - no subscript required
b) standard “for” loop - using a subscript

Code for you to copy:


     string[] myStates = new string[3];
     int[] myIntegerArray = new int[10];

Screen shots from the video example (cannot copy from here):

Video Demonstration:

Filed under C# Arrays by Administrator

Permalink Print 1 Comment