我有以下课程:
class Department
{
private string departmentId;
private string departmentName;
private Hashtable doctors = new Hashtable();//Store doctors for
//each department
public Hashtable Doctor
{
get { return doctors; }
}
}
我有一个包含部门对象的数组列表:
private static ArrayList deptList = new ArrayList();
public ArrayList Dept
{
get { return deptList; }
}
我正在尝试从每个部门获取所有医生(部门类中的哈希表):
foreach (Department department in deptList)
{
foreach (DictionaryEntry docDic in department.Doctor)
{
foreach (Doctor doc in docDic.Value)//this is where I gets an error
{
if (doc.ID.Equals(docID))//find the doctor specified
{
}
}
}
}
但我无法编译程序。它给出了一个错误:
foreach statement cannot operate on variables of type 'object' because
'object' does not contain a public definition for 'GetEnumerator'