- The reverse operator outputs a sequence of the same type as the input sequence but in the reverse order.
- It returns void
- Example
class Point
{
public int x { get; set; }
public int y { get; set; }
}
class Program
{
static void Main(string[] args)
{
List<Point> Points = new List<Point> {
new Point(){ x=10, y=20 },
new Point(){ x=-1, y=23 },
new Point(){ x=-4, y=-9 },
new Point(){ x=50, y=67 },
};
Points.Reverse();
foreach (var item in Points)
{
Console.WriteLine($"{item.x} {item.y}");
}
Console.ReadLine();
}
}
//Output
50 67
-4 -9
-1 23
10 20
{
public int x { get; set; }
public int y { get; set; }
}
class Program
{
static void Main(string[] args)
{
List<Point> Points = new List<Point> {
new Point(){ x=10, y=20 },
new Point(){ x=-1, y=23 },
new Point(){ x=-4, y=-9 },
new Point(){ x=50, y=67 },
};
Points.Reverse();
foreach (var item in Points)
{
Console.WriteLine($"{item.x} {item.y}");
}
Console.ReadLine();
}
}
//Output
50 67
-4 -9
-1 23
10 20
No comments:
Post a Comment