System.Collections.Generic.SortedList accessing

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • newscorrespondent@charter.net

    System.Collections.Generic.SortedList accessing

    I have a list declared:

    public System.Collecti ons.Generic.Sor tedList<int,
    System.Collecti ons.Generic.Lis t<MTGTracer ActiveList
    = new SortedList<int, List<MTGTracer> >();

    The key is an integer and the value is a list of MTGTracer.

    The documentation states:

    This property provides the ability to access a specific element in the
    collection by using the following syntax: myCollection[key].

    This code appears to work fine.

    int KeyIndex1 = ActiveList.Inde xOfKey(TraceDat a.ThreadID);
    if (ActiveList[KeyIndex1].Count == 1)
    { do somethinthing.
    }

    How can I access a specific member of the MTGTracer list.
    I have tried

    ActiveList[KeyIndex1].[2].TicksInCalledR outines
    to access the second in the list but the compiler wants an identifier to go
    along with the [2].

    What is the identifier?

    Thanks
    Tom
  • Joachim

    #2
    Re: System.Collecti ons.Generic.Sor tedList accessing

    Hi Tom,

    use

    ActiveList[TraceData.Threa dID][2]

    This should work.

    Joachim


    newscorresponde nt@charter.net schrieb:
    I have a list declared:
    >
    public System.Collecti ons.Generic.Sor tedList<int,
    System.Collecti ons.Generic.Lis t<MTGTracer ActiveList
    = new SortedList<int, List<MTGTracer> >();
    >
    The key is an integer and the value is a list of MTGTracer.
    >
    The documentation states:
    >
    This property provides the ability to access a specific element in the
    collection by using the following syntax: myCollection[key].
    >
    This code appears to work fine.
    >
    int KeyIndex1 = ActiveList.Inde xOfKey(TraceDat a.ThreadID);
    if (ActiveList[KeyIndex1].Count == 1)
    { do somethinthing.
    }
    >
    How can I access a specific member of the MTGTracer list.
    I have tried
    >
    ActiveList[KeyIndex1].[2].TicksInCalledR outines
    to access the second in the list but the compiler wants an identifier to go
    along with the [2].
    >
    What is the identifier?
    >
    Thanks
    Tom

    Comment

    • newscorrespondent@charter.net

      #3
      Re: System.Collecti ons.Generic.Sor tedList accessing

      Yes that did work great.

      Thanks
      Tom

      Comment

      Working...