The System.Collections.Generic is a package library in C# that provides a set of interfaces and classes for building generic collection classes. One of the classes in this package is the List class, which represents an ordered collection of items.
The List class provides several methods to manipulate the collection. The Reverse method is one of them, which reverses the order of the elements in a list. Here are some examples of using the Reverse method:
Example 1: Reversing a list of integers
List numbers = new List { 1, 2, 3, 4, 5 };
numbers.Reverse();
// output: 5 4 3 2 1
Example 2: Reversing a list of strings
List names = new List { "John", "Mary", "Peter", "Alice" };
names.Reverse();
// output: Alice Peter Mary John
In both examples, the Reverse method is called on a List object, which reverses the order of its elements.
To use the List class and its methods, you need to add the System.Collections.Generic namespace to your code:
using System.Collections.Generic;
C# (CSharp) System.Collections.Generic System.Collections.Generic.List.Reverse - 19 examples found. These are the top rated real world C# (CSharp) examples of System.Collections.Generic.System.Collections.Generic.List.Reverse extracted from open source projects. You can rate examples to help us improve the quality of examples.