I often come across code like the following:
if ( items != null)
{
foreach(T item in items)
{
//...
}
}
Basically, the
The real takeaway here should be a sequence should almost never be null in the first place. Simply make it an invariant in all of your programs that if you have a sequence, it is never null. It is always initialized to be the empty sequence or some other genuine sequence.
If a sequence is never null then obviously you don't need to check it.