Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save Silence2100/f70811f6e5d126545aef6fc32ef5aa88 to your computer and use it in GitHub Desktop.
Save Silence2100/f70811f6e5d126545aef6fc32ef5aa88 to your computer and use it in GitHub Desktop.
Объединение в одну коллекцию
using System;
using System.Collections.Generic;
namespace Task003
{
internal class Program
{
static void Main(string[] args)
{
string[] words1 = new string[] {"привет", "пока", "собака", "кошка", "привет"};
string[] words2 = new string[] {"кошка", "лошадь", "корова", "пока"};
List<string> allWords = new List<string>();
AddInList(allWords, words1);
AddInList(allWords, words2);
PrintList(allWords);
}
static void AddInList(List<string> allNumbers, string[] numbers)
{
for (int i = 0; i < numbers.Length; i++)
{
if (allNumbers.Contains(numbers[i]) == false)
{
allNumbers.Add(numbers[i]);
}
}
}
static void PrintList(List<string> words)
{
foreach (string word in words)
{
Console.Write(word + " ");
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment