Nov 09, 2017 05:26 PM|PatriceSc|LINK
Reverse doesn't produce a new reversed list. The current list is updated. So in short your code should just be :
As a side note is this is your full code ? You are just testing ? It seems you'll run into another error (trying to access a non existing element plus reversing the list seems to serve no purpose at all).
Edit: ah missed what you needed. So you want to use (from
https://msdn.microsoft.com/en-us/library/sey5k5z4(v=vs.110).aspx ) :
train.InsertAt(wagonId,0); // will always insert at the beginning of the list without having to reverse/unreverse.
IMO when you start to work with a class which is not familiar always have a look at the doc to get an idea about its capabilities.