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

51,839 answers

573 users

How to access a Dictionary with two-dimensional arrays in VB.NET

1 Answer

0 votes
Imports System
Imports System.Collections.Generic

Public Class Program
	Public Shared Sub Main()
        Dim dict As Dictionary(Of String, Integer(,)) = New Dictionary(Of String, Integer(,))()
        dict("matrix1") = New Integer(,) {
        {1, 2},
        {3, 4}}
        dict("matrix2") = New Integer(,) {
        {5, 6},
        {7, 8}}
		
        Dim matrix1 As Integer(,) = dict("matrix1")
        Dim matrix2 As Integer(,) = dict("matrix2")

        For i As Integer = 0 To matrix1.GetLength(0) - 1
            For j As Integer = 0 To matrix1.GetLength(1) - 1
                Console.Write(matrix1(i, j) & " ")
            Next

            Console.WriteLine()
        Next

        Dim value As Integer = dict("matrix2")(1, 1)
        Console.WriteLine("Element at [1,1] in matrix2 = " & value)
    End Sub
End Class


' run:
'
' 1 2 
' 3 4 
' Element at [1,1] in matrix2 = 8
'

 



answered Jan 21, 2025 by avibootz

Related questions

1 answer 52 views
1 answer 98 views
1 answer 189 views
2 answers 236 views
1 answer 59 views
...