Hack Forums
[.NET] Arrays inside array? VB.NET - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118)
+---- Thread: [.NET] Arrays inside array? VB.NET (/showthread.php?tid=6243637)



Arrays inside array? VB.NET - pzychonaut - Jun 8, 2023

So I want to store four values <DOMAIN> <IP> <PORT> <RESOURCE> and place them into an array. However, I want all four of those values to have a single index in the array, where i can call each of the values individually from said index. I will be adding many of these "four value" entries in the main array.

Sort of like: Dim demo_Value As String = myArray.Index(0).Item(3)

Is this possible? I feel like this would work similarly to a Python dictionary but I'm not sure.


RE: Arrays inside array? VB.NET - padrino - Jun 8, 2023

I think what you're referring to here in terms of an "Array inside an array" is a 2 dimensional array. Just try googling Array dimensions and you'll find Microsoft's learning page on it for VB.

If it were me though I would just create an class object with those 4 attributes and create a collection of those objects. the you can access them exactly as you need to and it would be far easier to read.

Hope this helps!


RE: Arrays inside array? VB.NET - Faith Connors - Jun 8, 2023

^the correct answer
but if you're not implementing logic on the data itself, then a simple struct will suffice over a full class


RE: Arrays inside array? VB.NET - padrino - Jun 8, 2023

(Jun 8, 2023 04:00 PM)Faith Connors Wrote:  ^the correct answer
but if you're not implementing logic on the data itself, then a simple struct will suffice over a full class

yah good point - struct will also work.


RE: Arrays inside array? VB.NET - pzychonaut - Jun 8, 2023

(Jun 8, 2023 03:53 PM)padrino Wrote:  I think what you're referring to here in terms of an "Array inside an array" is a 2 dimensional array. Just try googling Array dimensions and you'll find Microsoft's learning page on it for VB.

If it were me though I would just create an class object with those 4 attributes and create a collection of those objects. the you can access them exactly as you need to and it would be far easier to read.

Hope this helps!

(Jun 8, 2023 04:00 PM)Faith Connors Wrote:  ^the correct answer
but if you're not implementing logic on the data itself, then a simple struct will suffice over a full class

Thank you both for the help! I figured there was a fix but I was having trouble locating the solution. Cheers 😎


RE: Arrays inside array? VB.NET - padrino - Jun 8, 2023

(Jun 8, 2023 04:14 PM)pzychonaut Wrote:  Thank you both for the help! I figured there was a fix but I was having trouble locating the solution. Cheers 😎

no problem mate - happy coding!