Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- namespace Clight_54_CombineArraysToCollection
- {
- class Program
- {
- static void Main(string[] args)
- {
- string[] firstTexts = new string[] { "Четвертая строка", "Первая строка", "Первая строка", "Вторая строка", "Третья строка", "Вторая строка" };
- string[] secondTexts = new string[] { "Четвертая строка", "Вторая строка", "Пятая строка", "Вторая строка" };
- List<string> combineTexts = new List<string>();
- AddTextsToList(firstTexts, combineTexts);
- AddTextsToList(secondTexts, combineTexts);
- foreach (var text in combineTexts)
- Console.WriteLine(text);
- Console.ReadKey();
- }
- public static void AddTextsToList(string[] addTexts, List<string> combineTexts)
- {
- for (int i = 0; i < addTexts.Length; i++)
- {
- if(combineTexts.Contains(addTexts[i]) == false)
- combineTexts.Add(addTexts[i]);
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment