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,933 questions

51,870 answers

573 users

How to get unique values from two arrays in VB.NET

1 Answer

0 votes
Imports System
Imports System.Linq

Public Class Program
	Public Shared Sub Main()
        Dim arr1 As Integer() = {1, 3, 6, 8, 12, 90}
        Dim arr2 As Integer() = {2, 3, 5, 6, 7, 8, 96}
        
		Dim result = get_unique_values(arr1, arr2)
		
        Console.WriteLine(String.Join(", ", result))
    End Sub

    Private Shared Function get_unique_values(ByVal arr1 As Integer(), ByVal arr2 As Integer()) As Integer()
        Dim diff1 = arr1.Except(arr2)
        Dim diff2 = arr2.Except(arr1)
		
        Dim result = diff1.Concat(diff2).OrderBy(Function(n) n).ToArray()
			
        Return result
    End Function
End Class


' run:
'
' 1, 2, 5, 7, 12, 90, 96
'

 



answered Feb 16, 2025 by avibootz

Related questions

1 answer 123 views
2 answers 77 views
1 answer 114 views
1 answer 78 views
1 answer 73 views
1 answer 74 views
1 answer 141 views
...