Skip to main content
formatting
Source Link
takrl
  • 6.5k
  • 3
  • 63
  • 71

I found this one helpful

    public static IEnumerable<T> EmptyIfNull<T>(this IEnumerable<T> pSeq)
    {
        return pSeq ?? Enumerable.Empty<T>();
    }

It removes the null check in the calling code. You could now do

MyList.EmptyIfNull().Where(....)

I found this one helpful

    public static IEnumerable<T> EmptyIfNull<T>(this IEnumerable<T> pSeq)
    {
        return pSeq ?? Enumerable.Empty<T>();
    }

It removes the null check in the calling code. You could now do

MyList.EmptyIfNull().Where(....)

I found this one helpful

public static IEnumerable<T> EmptyIfNull<T>(this IEnumerable<T> pSeq)
{
    return pSeq ?? Enumerable.Empty<T>();
}

It removes the null check in the calling code. You could now do

MyList.EmptyIfNull().Where(....)
Post Made Community Wiki
Source Link

I found this one helpful

    public static IEnumerable<T> EmptyIfNull<T>(this IEnumerable<T> pSeq)
    {
        return pSeq ?? Enumerable.Empty<T>();
    }

It removes the null check in the calling code. You could now do

MyList.EmptyIfNull().Where(....)