I have a question about changing list items in C #.
The ultimate goal is to get the last N list items.
Suppose I have a list of decimal places.
List<decimal> listOfDecimals = new List<decimal>() { 1.5m, 2.4m, 3.6m, 0.1m };
This is my attempt to get a list containing the last 2 elements of listOfDecimals.
List<decimal> listOfLastTwoElements = listOfDecimals.Reverse<decimal>().Take<decimal>(2).Reverse<decimal>().ToList<decimal>();
My question is: if I replaced Reverse <> () with Reverse (), there will be a syntax error noted by VS.
Can someone please tell me when should I use Reverse () and when to use Reverse <> ()?
source
share