new Articulo[10]
just creates a reference to array that can contain references to 10 Articulo
. You still need to populate the array by allocating each Articulo
and storing the reference in the array. Java works the same way.Articulo
s are also created at the same time, it is time to review what you have learned about C# arrays. They only time C# will allocate those 10 Articulo
s will be if Articulo
is a value type instead of a reference type. (E.g struct
vs. class
)Articulo[] articulos = new Articulo[10];
Articulo articulo0;
Articulo articulo1;
Articulo articulo2;
Articulo articulo3;
Articulo articulo4;
Articulo articulo5;
Articulo articulo6;
Articulo articulo7;
Articulo articulo8;
Articulo articulo9;
articulo6.CodigoMarca = 3;
var p = new Person();
var p1 = new Person();
var p2 = new Person();
...
for(int x = 1; x<=2; x++){
Console.Write((p+x).Name);
}
x
is a reference type, you need to fill in the egg carton as mentioned above.x
is a value type, the carton comes pre-filled.The data type is there:well, supposedly an array is defined with data type x eg int[] array name= new int[n]..here it doesn't say if it's float,double or ,etc...that's what my question was about
int[] array name= new int[n]