Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace Add_in_one_collection
- {
- internal class Program
- {
- static void Main(string[] args)
- {
- List<string> list = new List<string>();
- string[] numbersInFirstString = { "2", "4", "6", "9", "1" };
- string[] numbersInSecondString = { "3", "2", "8", "4", "6", "9" };
- AddAllUniqueValuesInList(list, numbersInFirstString, numbersInSecondString);
- foreach (string value in list)
- {
- Console.Write(value + " ");
- }
- }
- static void AddUniqueValuesInList(List<string> list, string[] array)
- {
- foreach (string value in array)
- {
- if (!list.Contains(value))
- {
- list.Add(value);
- }
- }
- }
- static void AddAllUniqueValuesInList(List<string> list, string[] array1, string[] array2)
- {
- AddUniqueValuesInList(list, array1);
- AddUniqueValuesInList(list, array2);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement