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

51,791 answers

573 users

How to cross joins two arrays and get cartesian product using Linq in VB.NET

1 Answer

0 votes
Imports System
Imports System.Linq

Public Class Program
	Public Shared Sub Main()
        Dim arr_str As String() = {"c#", "c", "java", "python", "dart"}
        Dim arr_num As Integer() = {1, 2, 3, 4}

		Dim result = From f In arr_str
                 From a In arr_num
                 Select New With { _
                    Key.Language = f, _
                    Key.Number = a _
                 }
			
        For Each r In result
            Console.WriteLine(String.Format("{0} {1}", r.Language, r.Number))
        Next
    End Sub
End Class




' run:
'
' c# 1
' c# 2
' c# 3
' c# 4
' c 1
' c 2
' c 3
' c 4
' java 1
' java 2
' java 3
' java 4
' python 1
' python 2
' python 3
' python 4
' dart 1
' dart 2
' dart 3
' dart 4
' 

 



answered Jan 3, 2023 by avibootz

Related questions

2 answers 129 views
1 answer 257 views
3 answers 124 views
4 answers 169 views
1 answer 106 views
...