Queryable Union 메서드를 사용하여 두 시퀀스에 대해 Union을 수행합니다.
다음은 배열입니다.
int[] arr1 = { 29, 40, 15, 55, 70, 30, 90 };
int[] arr2 = { 30, 36, 40, 18, 15, 55, 75 }; 이제 Union 메서드를 사용하여 배열의 Union을 가져옵니다.
arr1.AsQueryable().Union(arr2);
예시
using System;
using System.Linq;
using System.Collections.Generic;
public class Demo {
public static void Main() {
int[] arr1 = { 29, 40, 15, 55, 70, 30, 90 };
int[] arr2 = { 30, 36, 40, 18, 15, 55, 75 };
IEnumerable<int> res = arr1.AsQueryable().Union(arr2);
foreach (int a in res)
Console.WriteLine("{0} ", a);
}
} 출력
29 40 15 55 70 30 90 36 18 75