Created
May 24, 2025 17:08
-
-
Save vohahudozhnik/dd68443cec6f0098ae2f8ea08a9a9ef4 to your computer and use it in GitHub Desktop.
ДЗ: Объединение в одну коллекцию 2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
namespace Training1 | |
{ | |
internal class Program | |
{ | |
static void Main(string[] args) | |
{ | |
string[] texts1 = { "Игорь", "Рома", "Вова", "Игорь", "Вася" }; | |
string[] texts2 = { "Вася", "Рома", "Даша", "Маша", "Вова" }; | |
List<string> texts3 = new List<string>(); | |
RemoveRepetitions(texts1, texts3); | |
RemoveRepetitions(texts2, texts3); | |
foreach (string text in texts3) | |
{ | |
Console.Write(text + " "); | |
} | |
} | |
static void RemoveRepetitions(string[] texts, List<string> texts3) | |
{ | |
foreach (string text in texts) | |
{ | |
if (texts3.Contains(text) == false) | |
{ | |
texts3.Add(text); | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment