Sorting on C# arrays using OrderBy -
i using orderby create new sorted array suggested in post sort array of items using orderby<> .
var sorted = sharepointlist.orderby(item => item.gettaborder()).toarray();
where, sharepointlist array of objects contains attributes including int taborder , gettaborder getter 'taborder' attribute
but throws below exception. please help
nullreferenceexception
object reference not set instance of object.
thanks in advance, sagarika
the problem have null value in sharepointlist
. if do;
var sorted = sharepointlist.where(x => x != null).orderby(item => item.gettaborder()).toarray();
it prevent exception, null values excluded result.
your entire list null in case need;
if (sharepointlist != null) //order in here else //handle error
Comments
Post a Comment