我在循环一组XElements
. 这种行为不是我所期望的。
我的代码的简短重写版本,因此您可以轻松解决我的问题(C# 中的控制台应用程序)
IEnumerable<XElement> q = from c in xml.Descendants(aw + "wd")
where (....)
select c;
...
//--------------------------------------------------------------------
IEnumerable<XElement> currRow = q.OrderBy(yyy => (int)yyy.Attribute("t"));
int xValue = 10;
currRow = currRow.Where(yyy => (int)yyy.Attribute("t") < xValue);
xValue = 20;
//Here, the currRow gets a new value automatically. I don't want this!
//--------------------------------------------------------------------
//This is want i want to acheive:
IEnumerable<XElement> currRow = q.OrderBy(yyy => (int)yyy.Attribute("t"));
int xValue = 10;
currRow = currRow.Where(yyy => (int)yyy.Attribute("t") < xValue);
//do somthing with currRow
xValue = 20;
currRow = currRow.Where(yyy => (int)yyy.Attribute("t") < xValue);
//do somthing else with currRow
xValue = 30;
currRow = currRow.Where(yyy => (int)yyy.Attribute("t") < xValue);
// etc....
有任何想法吗?