@iGoofy & JüTho: Dictionary kennt überhaupt keine Art von Sortierung, weder Standard- noch eigene

. Aber es geht wohl eher um die
Indizierung.
iGoofy hat folgendes geschrieben : |
| Brauche den Key für eine spätere Anwendung, deshalb Dictionary. |
Du brauchst ihn aber anscheinend nicht
als Key, sondern nur als Datum. Also ab in
Value damit:
C#-Quelltext
1: 2: 3: 4: 5: 6: 7: 8: 9: 10:
| Dictionary<int, KeyValuePair<int, string>> pairsByStringLength = ...
void Add(int i, string s) { pairsByStringLength.Add(s.Length, new KeyValuePair(i, s)); }
Add(42, "hi!");
pairsByStringLength[3].Key; |
Die Strings müssen natürlich alle unterschiedliche Längen haben, ansonsten ist Dictionary die falsche Datenstruktur.