bugDotGNU Portable.NET - Bugs: bug #10335, Enumerator problem with...

 
 

You are not allowed to post comments on this tracker with your current authentication level.

bug #10335: Enumerator problem with SortedList.Keys

Submitter:  Dominique Canazzi <canazzi>
Submitted:  Thu 09 Sep 2004 01:39:33 PM UTC
   
 
Category:  None Severity:  3 - Normal
Priority:  5 - Normal Item Group:  None
Status:  Fixed Privacy:  Public
Assigned to:  None Open/Closed:  Closed

Discussion

Thu 09 Sep 2004 02:24:57 PM UTC, comment #1: 

Patch #3355 applied to CVS fixes this.

Gopal.V <t3rmin4t0r>
Group administrator
Thu 09 Sep 2004 01:39:33 PM UTC, original submission:  

foreach(), applied to the ICollection returned by the Keys property of a SortedList, loses the first key.
Example:

using System;
using System.Collections;
namespace sl
{
  class Class1
  {
    static void Main()
    {
      SortedList sl = new SortedList ();
      sl.Add ("xxx", 1);
      sl.Add ("aaa", 2);
      sl.Add ("qqq", 3);
      sl.Add ("hhh", 4);
      foreach (String s in sl.Keys)
      {
        Console.WriteLine (s + " " + sl[s]);
      }
      Console.WriteLine ("---------------------------------");
      IList kl = sl.GetKeyList ();
      IList vl = sl.GetValueList ();
      for (int i=0; i<sl.Count; i++)
      {
        Console.WriteLine (kl[i] + " " + vl[i]);
      }
    }
  }
}
Should output:
aaa 2
hhh 4
qqq 3
xxx 1
---------------------------------
aaa 2
hhh 4
qqq 3
xxx 1
but outputs:
hhh 4
qqq 3
xxx 1
---------------------------------
aaa 2
hhh 4
qqq 3
xxx 1
Sorry for not proposing a fix, the pnetlib code is still a bit puzzling for me :)

Dominique Canazzi <canazzi>

 

Attached Files

This item currently has no attached files.

 

Dependencies

This item does not depend on any other items.

No items depend on this one.

 

Mail Notification Carbon-Copy List

 

Votes

There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

 

History

Follow 2 latest changes.

Date Changed by Updated Field Previous Value => Replaced by
2004-09-09 t3rmin4t0r StatusNone Fixed
    Open/ClosedOpen Closed

Back to the top

Powered by Savane 3.16-8b18.
Corresponding source code