实现在类似数组中查找最接近目标值的数值
定义链表
//定义链表
private List<int> xxxList;
//链表赋值
xxxList = new List<int>() { 0, 5,10,15,20,25,30 };
查找链表中最接近16的值,返回索引
int xxxIndex = xxxList.FindIndex(x => ((x-16) > -3));
或者
xxxIndex = xxxList.FindIndex(x => x.CompareTo(16) > 0);
查找当前元素在链表中的下标,返回值为-1 表示没有找到该元素
int xxxIndex= xxxList.FindIndex(x => x.Equals(15));