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. Advertisements

  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. Advertisements

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,944
    Victor Garcia Aprea [MVP]
    Apr 24, 2004
  2. Floela
    Replies:
    3
    Views:
    745
    Jon Skeet
    Jul 10, 2003
  3. Arjen
    Replies:
    1
    Views:
    7,942
    Carl Prothman [MVP]
    Aug 6, 2003
  4. Miguel Angel Dinelli
    Replies:
    1
    Views:
    573
    Chris Jackson
    Nov 13, 2003
  5. Roy Lawson
    Replies:
    12
    Views:
    5,792
  6. Brian Conway

    System.InvalidCastException

    Brian Conway, May 18, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    468
    Brian Conway
    May 18, 2004
  7. Miriam
    Replies:
    0
    Views:
    470
    Miriam
    Jul 8, 2004
  8. Biva
    Replies:
    6
    Views:
    2,790
    sqlgirl
    Jan 5, 2005
Loading...