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
Item Group:  None Status:  Fixed
Privacy:  Public Assigned to:  None
Open/Closed:  Closed

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>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

CC list is empty

 

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.

 

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.13-caa5.
Corresponding source code