Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save vohahudozhnik/dd68443cec6f0098ae2f8ea08a9a9ef4 to your computer and use it in GitHub Desktop.
Save vohahudozhnik/dd68443cec6f0098ae2f8ea08a9a9ef4 to your computer and use it in GitHub Desktop.
ДЗ: Объединение в одну коллекцию 2
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