Saturday, November 26, 2011

Arrays

You can use arrays when you have a fixed size collection of data with similar types.

Declaration

[VB] Dim v as Integer()

[CS] int[]

Initialization with specific size

[VB] Dim v as Integer() = new Integer(9){}

[CS] int[] v = new int[10]

Initialization with Data

[VB] Dim v as Integer() = {1,2,3,4}

[CS] int[] v = {1,2,3,4}

You can use object arrays, if you do not want to restrict your data to specific type.

No comments:

Post a Comment