标签:
Sub Main() Dim a As Integer() = {1, 2, 3, 4, 5, 6, 7} Dim b As Integer() = {4, 5, 6, 7, 8, 9, 10} Dim c As Integer() = {1, 2, 3, 3, 4, 1, 2, 4, 6, 1, 6, 5} ‘ 交集 Dim fuck = a.Intersect(b) ‘ 并集 Dim shit = a.Union(b) ‘ a有b没有的 Dim diff1 = a.Except(b) ‘ b有a没有的 Dim diff2 = b.Except(a) Dim max = a.Max() Dim min = a.Min() Dim avg = a.Average() Dim dis = c.Distinct() Print(fuck) Print(shit) Print(diff1) Print(diff2) Console.WriteLine(max) Console.WriteLine(min) Console.WriteLine(avg) Print(dis) Console.ReadKey() End Sub Private Sub Print(list As IEnumerable(Of Integer)) For Each item In list Console.Write(Convert.ToString(item) & " ") Next Console.WriteLine() End Sub
VB.NET LINQ 操作数组代码(求交集,并集,差集,最值,平均,去重复)
标签:
原文地址:http://www.cnblogs.com/lgx1972/p/4599020.html