I had some code that looked like this:
List<ListBoxItem> items = (
from String file in e.Result
select new ListBoxItem {
Content = file.Split('\\').Last(),
Tag = Content,
}).ToList<ListBoxItem>();
Here, after object creation, the result is not equivalent to
List<ListBoxItem> items = (
from String file in e.Result
select new ListBoxItem {
Content = file.Split('\\').Last(),
Tag = file.Split('\\').Last(),
}).ToList<ListBoxItem>();
Why are the resulting object initializations different?
Unless you have
Contentdeclared in the enclosing scope, your code is not even legal. You cannot refer to other properties of the object you are initializing while in the middle of initializing it.