Safiron

List merge

Aug 2nd, 2017
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.55 KB | None | 0 0
  1.         private void MergeListsOfCameras(ref List<Camera> list1, List<Camera> list2)
  2.         {
  3.             foreach (Camera c2 in list2)
  4.             {
  5.                 for (int i = 0; i < list1.Count; i++)
  6.                 {
  7.                     if (c2.Device == list1[i].Device)
  8.                         break;
  9.                     // We are at last element
  10.                     if (i - 1 == list1.Capacity)
  11.                         // Connected camera is not present in the list
  12.                         list1.Add(c2);
  13.                 }
  14.             }
  15.         }
Advertisement
Add Comment
Please, Sign In to add comment