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;

  • 相关阅读:
    根据excel表格中的某一列内容,使用python将其拆分成多个excel表格
    Python操作excel
    opensips(三):load_balancer与NAT
    opensips(二):NAT官方脚本
    sip头域
    OPensips(一):NAT例子
    四、word2vec + siameseLSTM改进(1)
    三、word2vec + siameseLSTM
    二、LSTM处理不定长句子
    一、word2vec的使用
  • 原文地址:https://www.cnblogs.com/wmalloc/p/6378807.html
Copyright © 2011-2022 走看看