osyris zosar

osyris zosar

  • NA
  • 289
  • 27.6k

How to get same value of multiple lists

Jan 4 2021 7:14 PM
Lets say  I have 4 lists
  1. List<int> list1 = new List<int>();    
  2. list1.Add(4);    
  3. list1.Add(5);    
  4. list1.Add(6);    
  5. list1.Add(7);    
  6. list1.Add(9);    
  7. list1.Add(1);    
  8.     
  9. List<int> list2 = new List<int>();    
  10. list1.Add(4);    
  11. list1.Add(7);    
  12. list1.Add(3);    
  13. list1.Add(0);    
  14.     
  15. List<int> list3 = new List<int>();    
  16. list1.Add(0);    
  17. list1.Add(5);    
  18.   
  19. List<int> list4 = new List<int>();    
  20. list1.Add(8);    
  21. list1.Add(5);    
  22. list1.Add(6);    
  23. list1.Add(7);    
  24. list1.Add(9);    
  25. list1.Add(1);    
  26. list1.Add(0);  
  27. list1.Add(3);  
  28. list1.Add(11);
i was thinking about starting with the list with the highest amount of number :  list4[A] than loop to each list and see if the other lists contain that number and do A+1
 
so it gets to next value in the list4 until it reaches the end of the list
 
but there must be a more easy way that i don't know of yet  

Answers (3)