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

Android : Making Listview full screen -

javascript - Parse JSON from the body of the POST -

javascript - Chrome Extension: Interacting with iframe embedded within popup -