Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

VB.NET list to dictionnary

Posted on 2015-02-11
2
Medium Priority
?
128 Views
Last Modified: 2015-02-11
Hello EE,

I got a list in vb.net  of strings

something like ;

01
3
02
9
03
1
04
0
05
5
06
8
07
1
08
1
etc...


it goes like that up to 100.  you see the pattern here.. actually its the number 01 to 100 and between them i have a value.
I would like to convert this to a dictionnary so that the key is the number 01 to 100 and the value is the value in between from the list...

can you help ?
thanks
0
Comment
Question by:PhilippeRenaud
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 75

Accepted Solution

by:
käµfm³d   👽 earned 2000 total points
ID: 40604141
Honestly, I think spelling this out in an old-skool For loop would be the easiest to read and understand.

e.g.

Module Module1

    Sub Main()
        Dim originalList As New List(Of String) From
        {
            "01",
            "3",
            "02",
            "9",
            "03",
            "1",
            "04",
            "0",
            "05",
            "5",
            "06",
            "8",
            "07",
            "1",
            "08",
            "1"
        }
        Dim theDictionary As New Dictionary(Of String, String)()

        For i As Integer = 0 To originalList.Count - 1 Step 2
            theDictionary.Add(originalList(i), originalList(i + 1))
        Next

        System.Diagnostics.Debugger.Break()
    End Sub

End Module

Open in new window

0
 
LVL 1

Author Closing Comment

by:PhilippeRenaud
ID: 40604152
Yup, I just thought to that and was about to delete my question haha.

Thank you Kaufmed =)
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question