码迷,mamicode.com
首页 > 编程语言 > 详细

VB.NET LINQ 操作数组代码(求交集,并集,差集,最值,平均,去重复)

时间:2015-06-25 01:18:31      阅读:183      评论:0      收藏:0      [点我收藏+]

标签:

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!