Results 1 to 4 of 4

Thread: How to write it in VB.NET?

  1. #1

    Thread Starter
    New Member
    Join Date
    Aug 2008
    Posts
    8

    Question How to write it in VB.NET?

    Creating a constant Dictionary in C#


    Code:
    Dictionary<string, int> ids = new Dictionary<string, int> { 
          {"abc",1}, {"def",2}, {"ghi",3} 
        };

    How to write the same in VB?

  2. #2
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,422

    Re: How to write it in VB.NET?

    vb Code:
    1. Dim ids As New Dictionary(Of String, Integer)
    2. ids.Add("abc", 1)
    3. ids.Add("def", 2)
    4. ids.Add("ghi", 3)

  3. #3

    Thread Starter
    New Member
    Join Date
    Aug 2008
    Posts
    8

    Re: How to write it in VB.NET?

    It's too obvious to be what I need in Sorry...

  4. #4
    Fanatic Member
    Join Date
    Jan 2006
    Posts
    710

    Re: How to write it in VB.NET?

    In VB10 (VS 2010), you can have:
    Code:
    Dim ids As New Dictionary(Of String, Integer)() From {{"abc",1}, {"def",2}, {"ghi",3}}
    David Anton
    Convert between VB, C#, C++, & Java
    www.tangiblesoftwaresolutions.com

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width