Hallo Alex, vielen Dank, ich denke das ist genau so was wie ich gesucht habe, ich muss das jetzt mal nach vb konvertieren und kucken ob ich das hinbekomme.
Vielen Dank schon mal Gr��e Dirk -----Urspr�ngliche Nachricht----- Von: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Im Auftrag von Alexander Zeitler Gesendet: Donnerstag, 10. Februar 2005 20:25 An: [email protected] Betreff: RE: [Asp.net] Elemente in ArrayList sortieren Hallo, hier ein Beispiel f�r eine Klasse ProductProperty, welche die Properties ProductPropertyID, ProductPropertyName, ProductPropertySign und productPropertyUnit hat. Gruss Alex P.S.: Bitte keine HTML-Mails. public class ProductPropertyCollection : ArrayList { public enum CollectionFields { ProductPropertyID, ProductPropertyName, ProductPropertySign, productPropertyUnit } public void Sort(CollectionFields sortField, bool isAscending) { switch (sortField) { case CollectionFields.ProductPropertyID: base.Sort(new ProductPropertyIDComparer()); break; case CollectionFields.ProductPropertyName: base.Sort(new ProductPropertyNameComparer()); break; case CollectionFields.ProductPropertySign: base.Sort(new ProductPropertySignComparer()); break; case CollectionFields.productPropertyUnit: base.Sort(new productPropertyUnitComparer()); break; } if (!isAscending) base.Reverse(); } private sealed class ProductPropertyIDComparer : IComparer { public int Compare(object x, object y) { ProductProperty first = (ProductProperty) x; ProductProperty second = (ProductProperty) y; return first.ProductPropertyID.CompareTo(second.ProductPropertyID); } } private sealed class ProductPropertyNameComparer : IComparer { public int Compare(object x, object y) { ProductProperty first = (ProductProperty) x; ProductProperty second = (ProductProperty) y; return first.ProductPropertyName.CompareTo(second.ProductPropertyName); } } private sealed class ProductPropertySignComparer : IComparer { public int Compare(object x, object y) { ProductProperty first = (ProductProperty) x; ProductProperty second = (ProductProperty) y; return first.ProductPropertySign.CompareTo(second.ProductPropertySign); } } private sealed class productPropertyUnitComparer : IComparer { public int Compare(object x, object y) { ProductProperty first = (ProductProperty) x; ProductProperty second = (ProductProperty) y; return first.ProductPropertyUnit.CompareTo(second.ProductPropertyUnit); } } } ich m�chte eine ArrayList sortieren, allerdings wei� ich nicht wie ich das anstellen soll. Inmeiner ArrayList gibt es eine unterschiedliche Anzahl an Elementen, jedes dieser Elemente besitzt ein Attribut �Position�, anhand dieser Position soll die ArrayList sortiert werden, wei� jemand Rat? Gr��e Dirk _______________________________________________ Asp.net Mailingliste, Postings senden an: [email protected] An-/Abmeldung und Suchfunktion unter: http://www.glengamoi.com/mailman/listinfo/asp.net _______________________________________________ Asp.net Mailingliste, Postings senden an: [email protected] An-/Abmeldung und Suchfunktion unter: http://www.glengamoi.com/mailman/listinfo/asp.net
