InvalidCastException

Discussion in 'ASP .Net Web Controls' started by Gary Wardell, Jul 17, 2008.

  1. Gary Wardell

    Gary Wardell Guest

    Hi,

    This doesn't seem to work. It throws an InvalidCastException.
    In general, when I'm trying to enumerate something, how do I find what type
    of object the enumerator returns? Help doesn't seem to be much help in this
    regard.

    Specifically, what type of object does the Session enumerator return?
    int i = 0;
    foreach (DictionaryEntry var in Session)
    {
    OutputBuffer =+ string.Format("(0) Key={1}, Value={2}", i, var.Key,
    var.Value);
    i++;
    }

    Gary
    Gary Wardell, Jul 17, 2008
    #1
    1. Advertising

  2. Gary Wardell

    Gary Wardell Guest

    Hi,

    Thanks, that helped.

    I was looking to iterate the keys and values. That gave the keys. I was
    expecting both in the same object.

    Gary
    Gary Wardell, Jul 17, 2008
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ajit
    Replies:
    1
    Views:
    3,585
    Victor Garcia Aprea [MVP]
    Apr 24, 2004
  2. Floela
    Replies:
    3
    Views:
    564
    Jon Skeet
    Jul 10, 2003
  3. Arjen
    Replies:
    1
    Views:
    7,756
    Carl Prothman [MVP]
    Aug 6, 2003
  4. Miguel Angel Dinelli
    Replies:
    1
    Views:
    442
    Chris Jackson
    Nov 13, 2003
  5. Roy Lawson
    Replies:
    12
    Views:
    5,157
Loading...

Share This Page