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