当我用 C# 构建我的第一个 UI 程序时,我遇到了一些麻烦!
假设我有两个类(Country, City),那么我将每个新Country对象设置在 AnArrayList之前创建并命名CountryList如下:
public static ArrayList CountryList = new ArrayList();
Country c1 = new Country(string name); // Creating Country object
CountryList.Add(c1); // Store the Object c1 in ArrayList
由于每个Country都有自己的Cities,所以我无法创建一个ArrayList将所有City对象存储在一起!
然后,我想要像ArrayList.