我想说我的代码正常工作,但我不知道它为什么这样工作。所以要清楚,这里是我的代码:循环列表并调整它
List<NewsFlash> newsfl = tsm.getNewsFlashes();
foreach (NewsFlash item in newsfl)
{
item.smartform.dtDate = item.smartform.dtDate.ToShortDateString();
}
//Get all the newsFlash items and bind to the repeater
rptNewsFlash.DataSource = newsfl;
rptNewsFlash.DataBind();
就像你所看到的,我是循环列表newsfl
,我编辑item.smartform.dtDate
。对我来说奇怪的是,当我编辑item.smartform.dtDate
时,那么列表newsfl
中的属性dtDate
也会更改。这是我想要的,但是我认为它有点奇怪,因为在foreach循环中的item
与列表newsfl
无关?
希望你能理解我的问题。
感谢
我正在测试这个。我想要创建另一个列表并添加循环中新创建列表中的所有项目。但我不知道这个功能,所以它现在变得更容易了。谢谢 – Ozkan