How to print the duplicate elements of an array in VB.NET

1 Answer

0 votes
Imports System
Imports System.Linq
				
Public Module Module1
	Public Sub Main()
		Dim array() As Integer = {3, 5, 9, 1, 7, 8, 1, 9, 0, 3, 9}
 
		Dim dup = From n In array
                  Group By n Into Group, Count()
                  Where Count > 1
                  Select n
                  Order By n

		Console.WriteLine(String.Join(",", dup)) 
	End Sub
End Module
	
	
	
' run:
'
' 1,3,9
'

 



answered May 3, 2020 by avibootz
edited May 4, 2020 by avibootz

Related questions

...