数组根据index拆分和查询下标

 private class ArrayTool<T>
{
/// <summary>查询值在数组中的下标</summary>
/// <param name="array">数组</param>
/// <param name="param">查询的参数</param>
/// <returns>下标</returns>
public static int ArrayQueryIndex(T[] array, T param)
{
for (int i = ; i < array.Length; i++)
if (array[i].Equals(param)) return i;
return ;
}
/// <summary>根据下标拆分出新数组</summary>
/// <param name="array">原数组</param>
/// <param name="EndIndex">结束下标</param>
/// <param name="StartIndex">开始下标</param>
/// <returns>新数组</returns>
public static T[] NewArrayByIndex(T[] array, int EndIndex, int StartIndex)
{
T[] result = new T[EndIndex - StartIndex + ];
for (int i = ; i <= EndIndex - StartIndex; i++) result[i] = array[i + StartIndex];
return result;
}
}
上一篇:Source Insight新建工程文件


下一篇:wx小程序-音频视频!