目录
11.Equals(Object)
12.Exists(Predicate)
13.Find(Predicate)
14.FindAll(Predicate)
15.FindIndex(Int32, Int32, Predicate)
16.FindIndex(Int32, Predicate)
17.FindIndex(Predicate)
C# List 详解一
1.Add(T),2.AddRange(IEnumerable),3.AsReadOnly(),4.BinarySearch(T),
C# List 详解二
5.Clear(),6.Contains(T),7.ConvertAll(Converter),8.CopyTo(Int32, T[], Int32, Int32),9.CopyTo(T[]),10.CopyTo(T[], Int32)
C# List 详解三
11.Equals(Object),12.Exists(Predicate),13.Find(Predicate),14.FindAll(Predicate),15.FindIndex(Int32, Int32, Predicate),16.FindIndex(Int32, Predicate),17.FindIndex(Predicate)
C# List 详解四
18.FindLast(Predicate),19.FindLastIndex(Int32, Int32, Predicate),20.FindLastIndex(Int32, Predicate),21.FindLastIndex(Predicate),22.ForEach(Action),23.GetEnumerator(),24.GetHashCode(),25.GetRange(Int32, Int32)
C# List 详解五
26.GetType(),27.IndexOf(T),28.IndexOf(T, Int32),29.IndexOf(T, Int32, Int32),30.Insert(Int32, T),31.InsertRange(Int32, IEnumerable),32.LastIndexOf(T),33.LastIndexOf(T, Int32),34.LastIndexOf(T, Int32, Int32)
C# List 详解六
35.MemberwiseClone(),36.Remove(T),37.RemoveAll(Predicate),38.RemoveAt(Int32),39.RemoveRange(Int32, Int32),40.Reverse(),41.Reverse(Int32, Int32)
C# List 详解七
42.Sort(),43.ToArray(),44.ToString(),45.TrimExcess(),46.TrueForAll(Predicate)
C# List 详解一_熊思宇的博客-CSDN博客
C# List 详解二_熊思宇的博客-CSDN博客
C# List 详解四_熊思宇的博客-CSDN博客
C# List 详解五_熊思宇的博客-CSDN博客
C# List 详解六_熊思宇的博客-CSDN博客
C# List 详解七_熊思宇的博客-CSDN博客
11.Equals(Object)
确定指定对象是否等于当前对象。继承自 Ojbect
public virtual bool Equals (object? obj);参数
 obj
 Object
 要与当前对象进行比较的对象。
返回
 Boolean
 如果指定的对象是等于当前对象,则为 true;否则为 false。
在引用类型的比较中,也就能自己比较自己才会 true,这和平时用的字符串比较差不多
案例:
using System;
using System.Collections.Generic;
namespace ListTest
{
    internal class Program
    {
        static void Main(string[] args)
        {
            List<int> list1 = new List<int>() { 1, 3, 5 };
            List<int> list2 = new List<int>() { 1, 3, 5 };
            bool isExists = list1.Equals(list2);
            Console.WriteLine(isExists);
            Console.ReadKey();
        }
    }
}运行:

自己比较自己,这里只是演示,不要这么写,哈哈
using System;
using System.Collections.Generic;
namespace ListTest
{
    internal class Program
    {
        static void Main(string[] args)
        {
            List<int> list1 = new List<int>() { 1, 3, 5 };
            List<int> list2 = new List<int>() { 1, 3, 5 };
            bool isExists = list1.Equals(list1);
            Console.WriteLine(isExists);
            Console.ReadKey();
        }
    }
}运行:

12.Exists(Predicate<T>)
确定 List<T> 是否包含与指定谓词定义的条件匹配的元素。
public bool Exists (Predicate<T> match);参数
 match
 Predicate<T>
 Predicate<T> 委托,用于定义要搜索的元素应满足的条件。
返回
 Boolean
 如果 List<T> 包含一个或多个元素与指定谓词定义的条件匹配,则为 true;否则为 false。
案例:
using System;
using System.Collections.Generic;
namespace ListTest
{
    internal class Program
    {
        static void Main(string[] args)
        {
            List<int> list1 = new List<int>() { 1, 3, 5 };
            bool isExists = list1.Exists(x => x == 5);
            Console.WriteLine(isExists);
            Console.ReadKey();
        }
    }
}运行:

13.Find(Predicate<T>)
搜索与指定谓词所定义的条件相匹配的元素,并返回整个 List<T> 中的第一个匹配元素。
public T? Find (Predicate<T> match);参数
 match
 Predicate<T>
 Predicate<T> 委托,用于定义要搜索的元素的条件。
返回
 T
 如果找到与指定谓词定义的条件匹配的第一个元素,则为该元素;否则为类型 T 的默认值。
案例:
using System;
using System.Collections.Generic;
namespace ListTest
{
    internal class Program
    {
        static void Main(string[] args)
        {
            List<int> list1 = new List<int>() { 1, 3, 5, 6 };
            int value = list1.Find(x => x > 3);
            Console.WriteLine(value);
            Console.ReadKey();
        }
    }
}运行:

14.FindAll(Predicate<T>)
检索与指定谓词定义的条件匹配的所有元素。
public System.Collections.Generic.List<T> FindAll (Predicate<T> match);参数
 match
 Predicate<T>
 Predicate<T> 委托,用于定义要搜索的元素应满足的条件。
返回
 List<T>
 如果找到一个 List<T>,其中所有元素均与指定谓词定义的条件匹配,则为该数组;否则为一个空 List<T>。
案例:
using System;
using System.Collections.Generic;
namespace ListTest
{
    internal class Program
    {
        static void Main(string[] args)
        {
            List<int> list1 = new List<int>() { 1, 3, 5, 6 };
            List<int> value = list1.FindAll(x => x > 3);
            Console.WriteLine(string.Join("-", value));
            Console.ReadKey();
        }
    }
}运行:

15.FindIndex(Int32, Int32, Predicate<T>)
搜索与指定谓词所定义的条件相匹配的一个元素,并返回 List<T> 中从指定的索引开始、包含指定元素个数的元素范围内第一个匹配项的从零开始的索引。
public int FindIndex (int startIndex, int count, Predicate<T> match);参数
 startIndex
 Int32
 从零开始的搜索的起始索引。
count
 Int32
 要搜索的部分中的元素数。
match
 Predicate<T>
 Predicate<T> 委托,用于定义要搜索的元素的条件。
返回
 Int32
 如果找到与 match 定义的条件相匹配的第一个元素,则为该元素的从零开始的索引;否则为 -1。
案例:
using System;
using System.Collections.Generic;
namespace ListTest
{
    internal class Program
    {
        static void Main(string[] args)
        {
            List<int> list1 = new List<int>() { 1, 3, 5, 6 };
            int index = list1.FindIndex(2, 2, x => x > 5);
            Console.WriteLine("下标:{0}", index);
            Console.ReadKey();
        }
    }
}运行:

16.FindIndex(Int32, Predicate<T>)
搜索与指定谓词所定义的条件相匹配的元素,并返回 List<T> 中从指定索引到最后一个元素的元素范围内第一个匹配项的从零开始的索引。
public int FindIndex (int startIndex, Predicate<T> match);参数
 startIndex
 Int32
 从零开始的搜索的起始索引。
match
 Predicate<T>
 Predicate<T> 委托,用于定义要搜索的元素的条件。
案例
using System;
using System.Collections.Generic;
namespace ListTest
{
    internal class Program
    {
        static void Main(string[] args)
        {
            List<int> list1 = new List<int>() { 1, 3, 5, 6 };
            int index = list1.FindIndex(2, x => x > 5);
            Console.WriteLine("下标:{0}", index);
            Console.ReadKey();
        }
    }
}运行:

17.FindIndex(Predicate<T>)
搜索与指定谓词所定义的条件相匹配的元素,并返回整个 List<T> 中第一个匹配元素的从零开始的索引。
public int FindIndex (Predicate<T> match);参数
 match
 Predicate<T>
 Predicate<T> 委托,用于定义要搜索的元素的条件。
返回
 Int32
 如果找到与 match 定义的条件相匹配的第一个元素,则为该元素的从零开始的索引;否则为 -1。
案例:
using System;
using System.Collections.Generic;
namespace ListTest
{
    internal class Program
    {
        static void Main(string[] args)
        {
            List<int> list1 = new List<int>() { 1, 3, 5, 6 };
            int index = list1.FindIndex(x => x == 5);
            Console.WriteLine("下标:{0}", index);
            Console.ReadKey();
        }
    }
}
运行:

第 3 / 7 篇 End




![[golang gin框架] 41.Gin商城项目-微服务实战之后台Rbac微服务(用户登录 、Gorm数据库配置单独抽离、 Consul配置单独抽离)](https://img-blog.csdnimg.cn/fdfc04e10b6c45d794307dfcf0c0c753.png)














