Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static void Main(string[] args)
- {
- int[] firstArray = { 1, 2, 1, 6 };
- int[] secondArray = { 3, 2, 4 };
- List<int> listNumbers = new List<int>();
- MergingIntoOneCollection(listNumbers, firstArray);
- MergingIntoOneCollection(listNumbers, secondArray);
- Console.Write("Список чисел без повторов: ");
- ShowList(listNumbers);
- Console.WriteLine();
- }
- private static void MergingIntoOneCollection(List<int> list, int[] array)
- {
- for (int i = 0; i < array.Length; i++)
- {
- if (list.Contains(array[i]) != true)
- {
- list.Add(array[i]);
- }
- }
- }
- private static void ShowList(List<int> list)
- {
- foreach (int i in list)
- {
- Console.Write(i + " ");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement