Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace HW
- {
- class Program
- {
- static void Main(string[] args)
- {
- string textFirst = "mauris rhoncus dictum lorem torquent per eu conubia nostra per inceptos himenaeos";
- string textSecond = "class aptent taciti semper scelerisque eu mauris fermentum lacinia lorem";
- string[] wordsFirst = textFirst.Split(' ');
- string[] wordsSecond = textSecond.Split(' ');
- Console.WriteLine(textFirst + " " + textSecond);
- List<string> newCollection = new List<string>();
- AddInCollection(newCollection, wordsFirst);
- AddInCollection(newCollection, wordsSecond);
- ShowCollection(newCollection);
- Console.ReadKey();
- }
- static void AddInCollection(List<string> collection, string[] words)
- {
- for (int i = 0; i < words.Length; i++)
- {
- if (AvailabilityInCollection(collection, words[i]) == false)
- {
- collection.Add(words[i]);
- }
- }
- }
- static void ShowCollection(List<string> collection)
- {
- foreach (var word in collection)
- {
- Console.Write(word + " ");
- }
- Console.WriteLine("\n\n");
- }
- static bool AvailabilityInCollection(List<string> newCollection, string word)
- {
- foreach (var item in newCollection)
- {
- if(item == word)
- {
- return true;
- }
- }
- return false;
- }
- }
- }
Add Comment
Please, Sign In to add comment