c# - Stuck with two dimensional array -


i'm trying create booking service , i've been stuck on part many hours , can't figure out i'm doing wrong.

so i've got 2 dimensional array , when trying print out stuff when testing , trying figure out what's wrong, system.string[] doesn't make me wiser. want able access details in i.e. m_namematrix[0,0] check whether seat reserved or not.

here's snippet form code:

private void updategui(string customername, double price) {     string selecteditem = cmddisplayoptions.items[cmddisplayoptions.selectedindex].tostring();     rbtnreserve.checked = true;     lstseats.items.clear();     lstseats.items.addrange(m_seatmngr.getseatinfostrings(selecteditem)); } 

and here 2 methods 2nd class:

public string[] getseatinfostrings(string selecteditem) {     int count = getnumofseats(selecteditem);      if (count <= 0)     {         return new string[0];     }     string[] strseatinfostrings = new string[count];      (int index = 0; index <= count; index++)     {         strseatinfostrings[index] = getseatinfoat(index);     }     return strseatinfostrings; }  public string getseatinfoat(int index) {     int row = (int)math.floor((double)(index / m_totnumofcols));     int col = index % m_totnumofcols;      string seatinfo = m_namematrix.getvalue(row, col).tostring();     return seatinfo; } 

i'm not getting exception might logical thinking that's been taking hit due hours , hours of trying figure out.

edit:

public void reserveseat(string name, double price, int index)     {         int row = (int)math.floor((double)(index / m_totnumofcols));         int col = index % m_totnumofcols;          string reserved = string.format("{0,3} {1,3} {2, 8} {3, 8} {4,22:f2}",                                         row + 1, col + 1, "reserved", name, price);          m_namematrix[row, col] = reserved;     } 

this line:

for (int index = 0; index <= count; index++) 

should be:

for (int index = 0; index < count; index++) 

why? lets have array 2 objects in it. count 2. however, indexes 0 , 1. have use less than operator.


Comments

Popular posts from this blog

javascript - DIV "hiding" when changing dropdown value -

Does Firefox offer AppleScript support to get URL of windows? -

android - How to install packaged app on Firefox for mobile? -