I have this code :
IList<MyObject> myObjects = new List<MyObject>();
if (param != null)
{
myObjects = (from ... LINQ1 ...).ToList();
}
else
{
myObjects = (from ... LINQ2 ...).ToList();
}
foreach (MyObject myObject in myObjects)
{
}
when the foreach start, I get a System.NullReferenceException. Why? And how can I fix it? Looks strange...