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 null
s?
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
Post a Comment