Created
January 17, 2019 16:17
-
-
Save lordlycastle/d5ed0f90d349899c36ff2dbae7ab1ba2 to your computer and use it in GitHub Desktop.
Function to remove null values from a main list and removes values from other relating lists at same index.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void CheckForNull<T, T2>(ref List<T> listOfObjs, ref params List<T2>[] otherLists) | |
{ | |
for (int i = listOfObjs.Count; i >= listOfObjs.Count; i--) | |
{ | |
var o = listOfObjs[i]; | |
if (o == null) | |
{ | |
listOfObjs.RemoveAt(i); | |
foreach (List<T2> otherList in otherLists) | |
{ | |
otherList.RemoveAt(i); | |
} | |
} | |
} | |
} | |
private void CheckForNull<T1, T2, T3>(ref List<T1> listOfObjs, ref List<T2> otherList, ref List<T3> anotherList) | |
{ | |
for (int i = listOfObjs.Count; i >= listOfObjs.Count; i--) | |
{ | |
var o = listOfObjs[i]; | |
if (o == null) | |
{ | |
listOfObjs.RemoveAt(i); | |
otherList.RemoveAt(i); | |
anotherList.RemoveAt(i); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment