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

Submitted by:  Dominique Canazzi <canazzi>
Submitted on:  Thu 09 Sep 2004 01:39:33 PM UTC  
 
Category: NoneSeverity: 3 - Normal
Item Group: NoneStatus: Fixed
Privacy: PublicAssigned 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>
Project 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>

 

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

CC list is empty

 

Do you think this task is very important?
If so, you can click here to add your encouragement to it.
This task has 0 encouragements so far.

Only logged-in users can vote.

 

Please enter the title of George Orwell's famous dystopian book (it's a date):

 

 

Follow 2 latest changes.

Date Changed By Updated Field Previous Value => Replaced By
Thu 09 Sep 2004 02:24:57 PM UTCt3rmin4t0rStatusNone=>Fixed
  Open/ClosedOpen=>Closed

Back to the top


Powered by Savane 3.1-cleanup1