Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Buy a domain name - Register cheap domain names from $0.99 - Namecheap

Scalable Hosting That Grows With You

Secure & Reliable Web Hosting, Free Domain, Free SSL, 1-Click WordPress Install, Expert 24/7 Support

Semrush - keyword research tool

Boost your online presence with premium web hosting and servers

Disclosure: My content contains affiliate links.

39,936 questions

51,873 answers

573 users

How to get the unique values of an array in VB.NET

2 Answers

0 votes
Imports System
Imports System.Linq

Public Class UniqueValuesOfAnArray
    Public Shared Sub Main(ByVal args As String())
        Dim arr As Integer() = {1, 2, 1, 1, 3, 3, 4, 4, 5, 5, 5, 5, 6, 7, 7, 8}

        Dim result = (From n In arr Select n).Distinct()

        For Each val In result
            Console.Write(val & " ")
        Next
    End Sub
End Class



' run:
'
' 1 2 3 4 5 6 7 8 
'

 



answered Feb 16, 2025 by avibootz
0 votes
Imports System
Imports System.Linq

Public Class UniqueValuesOfAnArray
    Public Shared Sub Main(ByVal args As String())
        Dim arr As Integer() = {1, 2, 1, 1, 3, 3, 4, 4, 5, 5, 5, 5, 6, 7, 7, 8}

        Dim result = arr.Distinct().ToArray()

        For Each val In result
            Console.Write(val & " ")
        Next
    End Sub
End Class



' run:
'
' 1 2 3 4 5 6 7 8 
'

 



answered Feb 16, 2025 by avibootz

Related questions

1 answer 67 views
3 answers 188 views
1 answer 130 views
1 answer 132 views
1 answer 105 views
...