Is an object still connected to a list after FirstOrDefault?
Posted
by Cynthia
on Stack Overflow
See other posts from Stack Overflow
or by Cynthia
Published on 2010-03-12T22:46:28Z
Indexed on
2010/03/12
22:47 UTC
Read the original article
Hit count: 218
Here's my code:
Event thisEvent = (from i in list
where (i.eventID == eventID)
select i).FirstOrDefault();
if (thisEvent != null)
{
thisEvent.eventResolved = resolved;
thisEvent.eventSequence.Add(item);
}
"list" is a collection of IEnumerable, i.e.
IEnumerable<Event> list;
What I'm wondering is: after creating thisEvent using FirstOrDefault, is thisEvent still connected to list? In other words, when I change the two properties, eventResolved and eventSequence, is "list" actually changed, or is thisEvent just some totally disconnected copy of an item in "list"?
© Stack Overflow or respective owner