When adding to a Dictionary (object), how do you check for duplicate keys?
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: When adding to a Dictionary (object), how do you check for duplicate keys?

  1. #1
    Join Date
    Sep 2000
    Posts
    200

    When adding to a Dictionary (object), how do you check for duplicate keys?

    Thanks for any help . . .


  2. #2
    Join Date
    Mar 2000
    Posts
    145

    Re: When adding to a Dictionary (object), how do you check for duplicate keys?

    There is an Exists method for the Dictionary object that is used to see if a specified key exists. If you try adding a key that already exists, you'll get an error.


    Dim d
    set d = new Dictionary
    if d.Exists("a") then
    msgbox "already exists!"
    else
    d.Add "a", "Athens"
    endif





Posting Permissions

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


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center