zane
zane

Reputation: 35

Creating objects in object array from a string array

When I print the object array out, the output is Project.Class. The intended output is to show each object.

The array has already been declared outside of the method.

I tried using mutators however the output was the same.

Upvotes: 0

Views: 150

Answers (2)

Fagun
Fagun

Reputation: 79

You can override ToString() method of that object class and emplement the method to return the specific properties what you want to print. And inisde a loop you can call that ToString() method of that object to print that object information.

Upvotes: 0

Sean T
Sean T

Reputation: 2494

The problem is your Console.WriteLine(stations[i]);. You've not posted your stations object definition but you need to reference what properties you want to show. Otherwise you will just write out your object.

Console.WriteLine(stations[i].stationNo);
Console.WriteLine(stations[i].stationName);

Upvotes: 3

Related Questions