I have a Linq query that looks something like this:
var myPosse = from p1 in people
select p1;
label1.Text = "All my peeps:" + Environment.NewLine;
foreach (Person p in myPosse)
{
this.label1.Text += p.ToString() + Environment.NewLine;
}
This gives me good results.
But when I do something like this:
var myPosse = from p1 in people
select p1;
label1.Text = "All my peeps:" + Environment.NewLine;
people.Add(new Person{FirstName="Don", LastName="Cash"});
foreach (Person p in myPosse)
{
this.label1.Text += p.ToString() + Environment.NewLine;
}
I have the 'extra' guy in there! How the heck is this happening? My Linq variable is set before the extra guy is added.