12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace Ropin.Inspection.Common.Helper
- {
- public class ListHelper<T>
- {
- public static void RemoveNull(List<T> list)
- {
- for (int i = list.Count - 1; i >= 0; i--)
- if (list[i] == null)
- list.RemoveAt(i);
- }
- public static void RemoveNullTwo(List<T> list)
- {
-
- int count = list.Count;
- for (int i = 0; i < count; i++)
- if (list[i] == null)
- {
-
- int newCount = i++;
-
- for (; i < count; i++)
- if (list[i] != null)
- list[newCount++] = list[i];
-
- list.RemoveRange(newCount, count - newCount);
- break;
- }
- }
- public static List<T> RemoveNullThree(List<T> oldList)
- {
- List<T> listTemp = new List<T>();
- for (int i = oldList.Count - 1; i >= 0; i--)
- if (oldList[i] != null)
- listTemp.Add(oldList[i]);
- return listTemp;
- }
- }
- }
|