我正在做一個家庭作業的項目,我有一個ArrayList包含5個字符串。我知道如何選擇ArrayList的項目(使用索引值),但不知道如何訪問對象字符串。任何幫助都會很棒。這是我一直試圖做的:選擇一個ArrayList中包含的對象
private ArrayList myComponents;
private int listIndex = 0;
myComponents = new ArrayList(); //Arraylist to hold catalog data
equipment = new Equipment(itemName, itemType, itemDetails, itemMaintenance, itemId);
myComponents.Add(equipment);
// class file is called Equipment.cs
// I know normally that equipment without the arraylist this would work:
// equipment.getitemName();
// but combining with the arraylist is being problematic.
「IndexOf」或「Contains」方法不是您需要在這裏使用的方法嗎? – 2009-11-20 17:42:45