Advertisement
JohnJuly

Homework37

Feb 28th, 2024 (edited)
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.07 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3.  
  4. namespace Hwork37
  5. {
  6.     internal class Program
  7.     {
  8.         static void Main(string[] args)
  9.         {
  10.             string[] arrayNumbersFirst = { "1", "2", "1", "4"};
  11.             string[] arrayNumbersSecond = { "3", "2", "9", "3"};
  12.  
  13.             List<string> combineNumbers = new List<string>();
  14.  
  15.             AddNumbersInList(combineNumbers, arrayNumbersFirst);
  16.             AddNumbersInList(combineNumbers, arrayNumbersSecond);
  17.             ShowList(combineNumbers);
  18.         }
  19.  
  20.         static void AddNumbersInList(List<string> listNumbers ,string[] arrayNumbers)
  21.         {
  22.             foreach (string number in arrayNumbers)
  23.             {
  24.                 if (listNumbers.Contains(number) == false)
  25.                 {
  26.                     listNumbers.Add(number);
  27.                 }
  28.             }
  29.         }
  30.  
  31.         static void ShowList(List<string> listNumbers)
  32.         {
  33.             foreach (string number in listNumbers)
  34.             {
  35.                 Console.WriteLine(number);
  36.             }
  37.         }
  38.     }
  39. }
  40.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement