我对这行代码有些问题:
if(String.IsNullOrEmpty(m_nameList[index]))
我做错了什么?
编辑:在VisualStudio中,m_nameList被红色下划线标出,并显示“当前上下文中不存在名称'm_nameList'”?
编辑2:我添加了一些代码。
class SeatManager
{
// Fields
private readonly int m_totNumOfSeats;
// Constructor
public SeatManager(int maxNumOfSeats)
{
m_totNumOfSeats = maxNumOfSeats;
// Create arrays for name and price
string[] m_nameList = new string[m_totNumOfSeats];
double[] m_priceList = new double[m_totNumOfSeats];
}
public int GetNumReserved()
{
int totalAmountReserved = 0;
for (int index = 0; index <= m_totNumOfSeats; index++)
{
if (String.IsNullOrEmpty(m_nameList[index]))
{
totalAmountReserved++;
}
}
return totalAmountReserved;
}
}
}