Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- namespace CSLight
- {
- internal class Program
- {
- static void Main()
- {
- List<string> joiningData = new List<string>();
- string[] firstArray = new string[12];
- string[] secondArray = new string[10];
- Console.CursorVisible = false;
- AddData(firstArray);
- AddData(secondArray);
- OutputArray(firstArray);
- Console.WriteLine("\n");
- OutputArray(secondArray);
- Console.ReadKey();
- JoinData(joiningData, firstArray);
- JoinData(joiningData, secondArray);
- Console.WriteLine("\n");
- foreach (var element in joiningData)
- {
- Console.Write($"{element} ");
- }
- Console.ReadKey();
- Console.Clear();
- }
- static void AddData(string[] array)
- {
- int minNumber = 0;
- int maxNumber = 25;
- Random random = new Random();
- for (int i = 0; i < array.Length; i++)
- {
- array[i] = Convert.ToString(random.Next(minNumber, maxNumber));
- }
- }
- static void JoinData(List<string> joiningData, string[] array)
- {
- for (int i = 0; i < array.Length; i++)
- {
- if (joiningData.Contains(array[i]) == false)
- {
- joiningData.Add(array[i]);
- }
- }
- }
- static void OutputArray(string[] array)
- {
- for (int i = 0; array.Length > i; i++)
- {
- Console.Write($"{array[i]} ");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment