using System;
using System.Collections.Generic; public class Example
{
public static void Main()
{
List<string> dinosaurs = new List<string>(); dinosaurs.Add("Pachycephalosaurus");
dinosaurs.Add("Parasauralophus");
dinosaurs.Add("Mamenchisaurus");
dinosaurs.Add("Amargasaurus");
dinosaurs.Add("Coelophysis");
dinosaurs.Add("Oviraptor"); Console.WriteLine();
foreach(string dinosaur in dinosaurs)
{
Console.WriteLine(dinosaur);
} dinosaurs.Reverse(); Console.WriteLine();
foreach(string dinosaur in dinosaurs)
{
Console.WriteLine(dinosaur);
} dinosaurs.Reverse(, ); Console.WriteLine();
foreach(string dinosaur in dinosaurs)
{
Console.WriteLine(dinosaur);
}
}
} /* This code example produces the following output: Pachycephalosaurus
Parasauralophus
Mamenchisaurus
Amargasaurus
Coelophysis
Oviraptor Oviraptor
Coelophysis
Amargasaurus
Mamenchisaurus
Parasauralophus
Pachycephalosaurus Oviraptor
Parasauralophus
Mamenchisaurus
Amargasaurus
Coelophysis
Pachycephalosaurus
*/

C# List(T).Reverse 方法 顺序反转的更多相关文章

  1. JavaScript Array reverse 方法:颠倒数组中元素的顺序

    在JavaScript中,Array对象的reverse()方法将颠倒(反转)数组中元素的顺序.arr.reverse()在原数组上实现这一功能,即,reverse()会改变原数组. 例1:将数组元素 ...

  2. 【转载】C#中List集合使用Reverse方法对集合中的元素进行倒序反转

    在C#的List集合操作中,有时候需要对List集合中的元素的顺序进行倒序反转操作,此时就可使用到List集合中的Reverse方法来实现此功能,Reverse方法的签名为void Reverse() ...

  3. JS对象 颠倒数组元素顺序reverse() reverse() 方法用于颠倒数组中元素的顺序。

    颠倒数组元素顺序reverse() reverse() 方法用于颠倒数组中元素的顺序. 语法: arrayObject.reverse() 注意:该方法会改变原来的数组,而不会创建新的数组. 定义数组 ...

  4. Python reverse()方法--list

    描述 reverse()方法:用于反转列表元素的排列顺序. 语法 语法格式:list.reverse() 参数 NA 返回值 无返回值 实例 #!/usr/bin/python3 a = ['abc' ...

  5. js数组中的reverse()方法

    reverse方法是将数组中的元素的顺序进行反转,在原数组上操作,然后返回原数组.由于本人是学习js的新人,对reverse函数进行了几个小实验,以下实验均在Chrome浏览器上运行 实验一:reve ...

  6. 关于splice()方法,slice() 、split()方法讲解,reverse()方法、replace()方法

    1.slice() 方法可从已有的数组中返回选定的元素. 语法 arrayObject.slice(start,end) 参数 描述 start 必需.规定从何处开始选取.如果是负数,那么它规定从数组 ...

  7. 数组中的元素 增加push用法 unshift() 方法 和减少pop() 方法 shift() 和其他位置增删 splice() 方法 join() 方法 reverse() 方法 sort() 方法

    push用法 push 英 [pʊʃ] 美 [pʊʃ] vt. 推,推动; vt. 按; 推动,增加; 对…施加压力,逼迫; 说服; n. 推,决心; 大规模攻势; 矢志的追求 定义和用法 push( ...

  8. Python 列表 reverse() 方法

    描述 Python 列表 reverse() 方法对列表中的元素进行反向排序. 语法 reverse() 方法语法: L.reverse() 参数 无. 返回值 该方法没有返回值,但是会对列表的元素进 ...

  9. Python List reverse()方法

    reverse() 函数用于反向列表中元素,参数 NA,该方法没有返回值,但是会对列表的元素进行反向排序,原来的列表被改变,生成新的列表. 例子:list1 = ['Google', 'Runoob' ...

随机推荐

  1. STL源码剖析--迭代器(转)

    一.为什么需要traits编程技术 前面说了很多关于traits的光荣事迹,但是却一直没有介绍traits究竟是个什么东西,究竟是用来干什么的?traits在英文解释中就是特性,下面将会引入trait ...

  2. 无需知道类名,就可以启动apk

    查看官方文档,发现这样一个方法: public abstract Intent getLaunchIntentForPackage (String packageName) 这个方法名就说明:根据包名 ...

  3. bit byte的关系

    字 word 字节 byte 位 bit 字长是指字的长度 1字=2字节(1 word = 2 byte) 1字节=8位(1 byte = 8bit)  一个字的字长为2个字节=2*8=16 一个字节 ...

  4. github基本命令

    https://github.com/explore 使用github网站搜索资源 具体搜索 Git教程 - 廖雪峰的官方网站 一. git配置命令 1.设置用户名 git config --glob ...

  5. C++: I/O流详解(二)——输入输出格式控制

    一.格式控制 ios提供直接设置标志字的控制格式函数 iostream和iomanip库还提供了一批控制符简化I/O格式化操作 状态标志 值 含义 输入/输出 skipws 0X0001 跳过输入中的 ...

  6. 使用pip安装离线包

    为了方便以后查看,特总结于此: 下载离线安装包并放到你想放的文件目录下 使用anaconda prompt安装离线文件 如果没有安装anaconda,则参照下边链接里边的操作!!! 离线环境通过pip ...

  7. EasyUi取消选中表格的所有行

  8. 【转】 PHP 两个日期(时间段) 之间的日期数组

    在开发过程中会遇到这样一个需求:获取2018-11-02到2018-11-15之间的日期数组 希望得到如下数组: Array ( [] => -- [] => -- [] => -- ...

  9. HiBench学习笔记

    HiBench资源及教程:https://github.com/intel-hadoop/HiBench 介绍: Hadoop新人 环境 linux 该笔记针对英语弱鸡&自己在使用过程用遇到的 ...

  10. freemarker常用标签解释遍历

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <hea ...