Created
May 31, 2022 03:46
-
-
Save son0nline/ea49b749f530eeac04829cd4ff8f410f to your computer and use it in GitHub Desktop.
ArrayList join
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections; | |
using System.Collections.Generic; | |
public class ArrayJoin{ | |
public ArrayJoin() | |
{ | |
ArrayList arrayList = new ArrayList(); | |
arrayList.Add(1); | |
arrayList.Add("two"); | |
arrayList.Add(3); | |
arrayList.Add("four"); | |
IList<string> strList1 = new List<string>(){"One", "Two", "Three", "Four", "Five" }; | |
IList<string> strList2 = new List<string>(){"Four", "Five", "Six", "Seven", "Eight"}; | |
Console.Write("-------------------"); | |
Console.WriteLine("Except"); | |
var resultExcept = strList1.Except(strList2); | |
foreach(string str in resultExcept) | |
Console.WriteLine(str); | |
Console.Write("-------------------"); | |
Console.WriteLine("Intersect"); | |
var resultIntersect = strList1.Intersect(strList2); | |
foreach(string str in resultIntersect) | |
Console.WriteLine(str); | |
Console.Write("-------------------"); | |
Console.WriteLine("Concat"); | |
var resultConcat = strList1.Concat(strList2); | |
foreach(string str in resultConcat) | |
Console.WriteLine(str); | |
Console.Write("-------------------"); | |
Console.WriteLine("Distinct"); | |
var resultDistinct = resultConcat.Distinct(); | |
foreach(string str in resultDistinct) | |
Console.WriteLine(str); | |
Console.Write("-------------------"); | |
Console.WriteLine("Union"); | |
var resultUnion = strList1.Union(strList2); | |
foreach(string str in resultUnion) | |
Console.WriteLine(str); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment