C# LINQ GroupBy with NULL values -


i have object dates:

class myobj {    public datetime? date {get; set;} } 

as can see date nullable. possible use linq's groupby method group list<myobj> dates including nulls?

to like: {elements_with_date_1, elements_with_date_2, ..., elements_with_no_date}?

the groupby-method extension-method, means static method accepts date parameter. written listwithnulls.groupby() treated groupby(listwithnulls). because of behavior, null-values can handled , don't nullreferenceexception.

have @ extension-methods definition. helps understand how can work them:

public static ienumerable<igrouping<tkey, tsource>> groupby<tsource, tkey>(this ienumerable<tsource> source, func<tsource, tkey> keyselector); 

you can see first argument written this ienumerable<tsource> source, enables short-handle source.groupby().


Comments

Popular posts from this blog

OpenCV OpenCL: Convert Mat to Bitmap in JNI Layer for Android -

android - org.xmlpull.v1.XmlPullParserException: expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope -

python - How to remove the Xframe Options header in django? -