• C# List<> Find相关接口学习


    参考

     http://blog.csdn.net/daigualu/article/details/54315564

    示例:

    List<int> test = new List<int>();

           [0]      [1]     [2]              [3]             [4]             [5]              [6]
    test.Add(9);test.Add(1);test.Add(9);test.Add(2);test.Add(9);test.Add(3);test.Add(9);


    int t1 = test.Find(test1 => test1 == 9); //结果 t1 = 9
    List<int> t2 = test.FindAll(test1 => test1 == 9);  //结果 t2 = {9, 9, 9, 9}
    int t3 = test.FindIndex(test1 => test1 == 9); //结果 t3 = 0
    int t4 = test.FindIndex(1, test1 => test1 == 9); //结果 t4 = 2; 从[1]开始的第一个=9的元素下标
    int t5 = test.FindIndex(1, 2, test1 => test1 == 9); //结果 t5 = 2 从[1]开始的2个元素内(即[1],[2]),查找第一个=9的元素的下标,如果第二个参数=1则无法找到,t5=-1;
    int t6 = test.FindLast(test1 => test1 == 9); //结果 t6 = 9
    int t7 = test.FindLastIndex(test1 => test1 == 9); //结果 t7 = 6
    int t8 = test.FindLastIndex(5, test1 => test1 == 9); //结果 t8 = 4 从[0]-[5]元素中,返回最后一个=9的元素的下标
    int t9 = test.FindLastIndex(3, 2, test1 => test1 == 9); //结果 t9 = 2 从[3]元素向前的2个元素内即([3],[2]),查找第一个=9的元素的下标,如果第二个参数=1,则无法找到,t9 = -1;

  • 相关阅读:
    Git 分支[转]
    监听键盘的输入事件[转]
    github for windows的初步使用
    限制一个form被同时打开的数量 Limite The Number of Forms Opened at the same time
    android内存检测工具
    面试 9.26 总结
    canvas path paint 的使用(游戏必备)
    android知识点
    android查缺补漏
    AIDL的使用
  • 原文地址:https://www.cnblogs.com/wmalloc/p/6378807.html
Copyright © 2020-2023  润新知