【发布时间】:2010-12-18 19:30:03
【问题描述】:
我正在做一个家庭作业项目,我有一个包含 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”方法不是您需要在这里使用的吗?