首页 > 编程语言 > 详细

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

时间:2015-06-25 01:17:38      阅读:1372      评论: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
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!