Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace CSLight
- {
- public class Program
- {
- static void Main(string[] args)
- {
- int[] arrayOne = new int[5] {1,2,3,3,5};
- int[] arrayTwo = new int[4] {3,5,5,4};
- List<int> numbers = new List<int>();
- AddToCollectionWithoutDuplicates(arrayOne, numbers);
- AddToCollectionWithoutDuplicates(arrayTwo, numbers);
- Console.WriteLine("Результат объединения без повторений:");
- foreach (var number in numbers)
- {
- Console.Write(number + " ");
- }
- }
- static void AddToCollectionWithoutDuplicates(int[] array, List<int> list)
- {
- for (int i = 0; i < array.Length; i++)
- {
- if (!list.Contains(array[i]))
- {
- list.Add(array[i]);
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement