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