>student []array = new student[x];
This creates an array of references to student objects. It doesn't create the actual student objects. You need to do that as well in your loop:
student[] array = new student[x];
for ( int i = 0; i < array.length; i++ ) {
array[i] = new student();
//...
}
>Console.WriteLine(array[0]);
That's not going to print the contents of a student object.
Narue
Bad Cop
15,460 posts since Sep 2004
Reputation Points: 6,464
Solved Threads: 1,401
>thanks alot but it didn't print the array elements
I know that. That's why I said, and I quote, because you obviously didn't read it: "That's not going to print the contents of a student object.".WriteLine doesn't know what a student class is, so how can you expect it to print the members correctly? It's treated as an object and printed accordingly. If you want to print the members, you do so manually:
Console.WriteLine ( array[0].name );
Console.WriteLine ( array[0].gender );
Console.WriteLine ( array[0].tel );
Console.WriteLine ( array[0].classe );
Clearly my original helpful comment wasn't enough for someone who wants to be spoonfed.
Narue
Bad Cop
15,460 posts since Sep 2004
Reputation Points: 6,464
Solved Threads: 1,401
>I'd advise to use an arraylist for that.
I'd advise against the non-generic collections unless you have a good reason (such as compatibility with the framework prior to .NET 2.0). Rather than ArrayList, use List<> from System.Collections.Generic.
Narue
Bad Cop
15,460 posts since Sep 2004
Reputation Points: 6,464
Solved Threads: 1,401