In the latest version of .Net 6, there are lots of enhancements on Linq.
I will directly go with the example as below:
Below is the output
As you can see, now you can get fetch nth last element and also all kind of other combination which I have showed in the above example
In the latest version of .Net 6 we have another nice Linq extension which will be very useful i.e. "MaxBy".
It will allow us to find the item with the max value for the particular property in a collection.
Below is the example:
.Net 6: MaxBy
In the existing code you might be first ordering by descending for a particular property and than get the first element. So instead of doing that we can just use "MaxBy" which will be very handy