我不能確定這是否是可能的ArrayList或解釋,或是否會是別的東西,如果是的話我不知道,你可以在正確的方向點我...ArrayList中有多個值C#
燦你有一個ArrayList有多個值,即
ArrayList weather = new ArrayList();
weather.Add("Sunny", "img/sunny.jpg");
weather.Add("Rain", "img/Rain.jpg);
爲了然後分配到控制像下面。
if (WeatherValue = 0)
{
Label1.Text = weather[0].ToString;
Image1.ImageUrl = weather[0].ToString;
}
或者,我可以做到這一點用字典
Dictionary<string, string> dict = new Dictionary<string, string>();
dict.Add("Cloudy", "../img/icons/w0.png"); //[0]
dict.Add("Rain", "../img/icons/w1.png"); //[1]
Label1.Text = dict[0].VALUE1; //So this would get Cloudy
Image.ImageUrl = dict[0].VALUE2; //This would get ../img/w0.png
你如何稱呼一個字典的值分別使用[0]和[1]?等
Theres沒有理由仍然使用'ArrayList',使用'System.Collections.Generic.List' -class –