T
Todd Smith
I have this code, but I get a runtime error that says arr[34] isn't
set to an instance of a class. So how do I initialize an array of
objects, calling all the constructors for each thing in the array?
-thanks
-todd
using System;
using System.Windows.Forms;
class Shape {
public int a;
public Shape() {
a = 1;
}
}
class A : Form {
public A() {
Shape[] arr = new Shape[100];
MessageBox.Show( arr[34].a.ToString() );
}
public static void Main() {
Application.Run( new A() );
}
}
set to an instance of a class. So how do I initialize an array of
objects, calling all the constructors for each thing in the array?
-thanks
-todd
using System;
using System.Windows.Forms;
class Shape {
public int a;
public Shape() {
a = 1;
}
}
class A : Form {
public A() {
Shape[] arr = new Shape[100];
MessageBox.Show( arr[34].a.ToString() );
}
public static void Main() {
Application.Run( new A() );
}
}