I have a single dimensional array of items declared and initialized as:
string[] SubDirectorylist = Directory.GetDirectories(TargetDirectory);
I'd like to reverse the members and found Enumerable.Reverse<TSource>()
.
What advantages, if any, does LINQ's implementation of reverse have over Array.Reverse()
?
Beside what Daniel told System.Linq.Enumerable.Reverse()
actually creates a copy then iterates it from end to beginning, when System.Array.Reverse()
does in place transformation.
System.Linq.Enumerable.Reverse()
works on all classes that implement IEnumerable
where as System.Array.Reverse()
only works on arrays. If you know that you have an array, there is nothing wrong with using System.Array.Reverse()
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With