C# Queryable Union 方法
使用 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
廣告
資料結構
網路
RDBMS
作業系統
Java
iOS
HTML
CSS
Android
Python
C 程式設計
C++
C#
MongoDB
MySQL
JavaScript
PHP