locked
can you use IEnumerable and IDictionayEnumerator together? RRS feed

  • Question

  • So I just had a question on a practice exam for the 70-536. It goes like this, "you are creating a new collection type for an application the collection type must be iterated through using a foreach loop. Which two interfaces should you use?" - before seeing the answer my first thought was IEnumerable and IEnumerator but it turns out that I didn't even have IEnumerator as an option. Long story short - the answer they say is correct is "IDictionaryEnumerator" and "IEnumerable" - assuming that is right can anyone point to an example of where or when I would combine these two?

     

    Thanks!

    Friday, June 18, 2010 9:41 PM

Answers

  • IDictionaryEnumerator and IEnumerable are clearly correct if there was some mention about there being keys and values.  Although you say it wasn't listed, stating all three: IDictionaryEnumerator, IEnumerable, and IEnumerator is reasonable: whenever you implement IDictionaryEnumerator, you automatically implement IEnumerator as well.

    However, if there is no discussion about keys and values, I would consider that practice question suspect.

    Saturday, June 19, 2010 12:14 AM
  • I'd like to see the exact question because the only reason to use IDictionaryEnumerator is when creating an enumerator for a key/value pair collection.
    Saturday, June 19, 2010 12:38 AM
  • Hi rok3t,

       Welcome to MSDN forums! I'm glad to see your active participation and discussion in MSDN forums. As far as we konw IDictionayEnumerator was implememts IEnumerator please refer to

        http://msdn.microsoft.com/en-us/library/system.collections.idictionaryenumerator.aspx 

        http://msdn.microsoft.com/en-us/library/system.collections.ienumerable.aspx 

       Hope this will help you!  

       If you still have any doubt and concern about this issue, please let me know. If I misunderstood you, please kindly elaborate your question.


    Please Mark as Answered If this is helpful Or Un-Mark as Answered if it is not helpful.

    Best Regards,
    Yan Jun
    Microsoft Online Community Support

    Friday, June 25, 2010 3:49 AM
    Moderator

All replies

  • IDictionaryEnumerator and IEnumerable are clearly correct if there was some mention about there being keys and values.  Although you say it wasn't listed, stating all three: IDictionaryEnumerator, IEnumerable, and IEnumerator is reasonable: whenever you implement IDictionaryEnumerator, you automatically implement IEnumerator as well.

    However, if there is no discussion about keys and values, I would consider that practice question suspect.

    Saturday, June 19, 2010 12:14 AM
  • I'd like to see the exact question because the only reason to use IDictionaryEnumerator is when creating an enumerator for a key/value pair collection.
    Saturday, June 19, 2010 12:38 AM
  • Hi rok3t,

       Welcome to MSDN forums! I'm glad to see your active participation and discussion in MSDN forums. As far as we konw IDictionayEnumerator was implememts IEnumerator please refer to

        http://msdn.microsoft.com/en-us/library/system.collections.idictionaryenumerator.aspx 

        http://msdn.microsoft.com/en-us/library/system.collections.ienumerable.aspx 

       Hope this will help you!  

       If you still have any doubt and concern about this issue, please let me know. If I misunderstood you, please kindly elaborate your question.


    Please Mark as Answered If this is helpful Or Un-Mark as Answered if it is not helpful.

    Best Regards,
    Yan Jun
    Microsoft Online Community Support

    Friday, June 25, 2010 3:49 AM
    Moderator