Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- namespace CollectionsTask5UniteArrays
- {
- internal class Program
- {
- static void Main(string[] args)
- {
- string[] worlds1 = { "aaa", "bbb", "ccc", "ddd", "bbb", "yyy" };
- string[] worlds2 = { "ggg", "ee", "dgfd", "bbb", "aaa", "xxx" };
- List<string> allWorlds = new List<string>();
- AddArrayToList(worlds1, allWorlds);
- AddArrayToList(worlds2, allWorlds);
- foreach (string item in allWorlds)
- {
- Console.WriteLine(item + " ");
- }
- Console.ReadKey();
- }
- private static void AddArrayToList(string[] array, List<string> list)
- {
- foreach (string item in array)
- {
- if(list.Contains(item) == false)
- {
- list.Add(item);
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement