IEnumerable<T> collection;
void MyMethod(T toSearch)
{
foreach (T t in collection)
if (t == toSearch) {}
}
The if clause is never true.. is it because the Enumerator creates all the items instances on demand, so everytime a new Reference ?
Edited:
Another question. What happens if I one of those collection elements return in T MyMethod() . Do I have a reference on an existing instance that really resides in memory so that all changes made on it will be reflected in that item.. or the returned element is a new instance.. or I cannot do that .. I don't understand