Overclock.net banner

1 - 6 of 6 Posts

·
Registered
Joined
·
1,073 Posts
Discussion Starter #1
Hey, I'm working on a lab for my C# class, but the program isn't running right. Part of the lab is to display 3 arrays: the models of some cars, their item numbers, and their prices. I've got everything error-free up to now. Whenever I run the program that's suppose to display the sorted arrays, I get this for an output:



I think I'm not passing something right...but I don't know what I"m doing wrong.
 

·
Premium Member
Joined
·
4,616 Posts
Blank outputs usually are a problem
 

·
Registered
Joined
·
1,073 Posts
Discussion Starter #3
I figured it out just now...I was looking through my book and there's this "foreach" loop I need to use.

Yea, I know it looks like a blank output, but I had it set up in my mind so that it would print them out, but I guess array's are displayed differently from a regular ol' statement
 

·
Registered
Joined
·
1,073 Posts
Discussion Starter #5
Sorry about that. What I changed was the very bottom part where it displays the array.



What I was trying to do was use the Console.WriteLine to display all 3 arrays, when I needed to use foreach to properly display it...I'm not very good at explaining this stuff, but hopefully you can gather what the general idea was behind what I did.


Now the question is how do I get all 3 arrays to show up, next to each other under their array list names...I'll see what I can do.
 

·
Registered
Joined
·
1,073 Posts
Discussion Starter #6
Sorry for double post.

Ok, scratch that entire last post. Turns out you CAN use the Console.WriteLine to display arrays...I was just using it wrong. You have to use a for loop, setting the limit to the number of items in the array, and when you go to type out the Console.WriteLine, you place the int i into the integral value of the array. Here's my new output, with all 3 arrays listed...except that last row is off center because of the name I think, but that should be easily fixable.


Again, very bottom of the pic is where the changes are made.

 
1 - 6 of 6 Posts
Top