Home > Software engineering >  Most efficient way to create searchable "array" in VB.NET
Most efficient way to create searchable "array" in VB.NET

Time:02-15

I would like to create a multidimensional array of some description in VB.NET that can store and search the following data efficiently (search on the second dimension, to return the first).

Folder Ext
excel xls
excel xlsx
word doc
word docx
powerpoint ppt
powerpoint pptx

CodePudding user response:

Dim data As New Dictionary(Of String, String) From {
    {"xls",  "excel"},
    {"xlsx", "excel"},
    {"doc",  "word"},
    {"docx", "word"},
    {"ppt",  "powerpoint"},
    {"pptx", "powerpoint"}
}

Access it like this:

Dim ext As String = "docx"
Dim folder As String = data(ext)
  • Related