0
我有以下代碼應該從來自服務器的字符串生成listitems。代碼如下:listitem中的值不準確
foreach (String str in years)
{
if (string.IsNullOrEmpty(str) || str.Equals(" "))
{
System.Diagnostics.Debug.WriteLine("empty");
}
else
{
System.Diagnostics.Debug.WriteLine(str);
yearLi.Value = str;
yearList.Add(yearLi);
count = yearList.Count;
}
System.Diagnostics.Debug.WriteLine("count-->" + count);
}
現在我的問題是,如果字符串數組「年」有{} 2011,2012名單應該是2011年和2012年,但它有2012,2012。我無法在此代碼中找到錯誤。請指教。
告訴我們你是如何初始化'年' – egrunin