TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Nova
NA
5
4.4k
Need help with "IndexOutOfRangeException was unhandled"
Oct 25 2012 7:33 AM
Hi,
I´m in a course for C# beginners. I´ve run into a little problem. I use this code for count "vacant" seats, "reserved seats" and "all seats" depending of which one´s selected in my Combobox. For example, if I select "vacant" should just all Vacant seats, with seatnumbers, names and prices be shown in the ListBox. Here´s my code:
public string[] GetSeatInfoAt(DisplayOptions choice)
{
string[] arrayList = new string[0]; //just creates an empty array
string status = null;
int n_vacant = 0;
int n_reserved = 0;
for (int i = 0; i < m_totNumOfSeats; i++ )
{
switch (choice)
{
case DisplayOptions.VacantSeats:
if (string.IsNullOrEmpty(m_nameList[i]))
{
status = "Vacant";
Array.Resize(ref arrayList, n_vacant);
arrayList[n_vacant] = string.Format("{0,3} {1,-8} {2,-25}{3,8:f2}", Convert.ToString(i + 1), status, m_nameList[i], m_priceList[i]);
n_vacant = n_vacant + 1; //För att räkna upp antal "Vacant"
}
break;
Reply
Answers (
6
)
need some code
why array start with 0th location