zoukankan      html  css  js  c++  java
  • 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;

  • 相关阅读:
    jmeter导出提取的值或参数化的值到excel
    超级有用的正则表达式
    性能测试监控
    asp.net 多线程
    VS代码格式化快捷键
    JS判断IE版本
    Jquery原创排序table
    将aspx转化为html代码
    Java基本语法——变量
    Entity Framework 中的LazyLoading
  • 原文地址:https://www.cnblogs.com/wmalloc/p/6378807.html
Copyright © 2011-2022 走看看