AW: [CSharp.net] Collection oder array?
Mansur Esmann [OM]
csharp.net at glengamoi.com
Tue, 18 May 2004 11:29:49 +0200
Sorry die Mail ist schneller rausgegangen als gewollt...
Hallo ...
das klingt gut.
Somit habe ich ja alle Möglichkeiten einer ArrayList auch zur verfügung (z.B. sort, oder
BinarySearch, oder was ich dann noch dazu implementiere ....
Womit ich aber ein Problem habe ist wie ich es einsetze:
public class GISPoint : PointMapShape, ArrayList
das geht ja nicht, weil an der Stelle eine Schnittstelle kommt ....
Heisst das ich sollte GISPoint als ArrayList definieren und darunter dann eine public - klasse
reintun, die den tatsächlichen GISPoint representiert?
Gruß Mansur
> > Hallo,
> >
> > >
> > > Das gibt mir aber den Fehler das ich nicht von GISPoint zu
> > > GISPoint[] wandeln kann ...
> > > auch klar ...
> > > Aber ich habe jetzt keine Ahnung wie ich die (Nennt man das
> > > so:) Collection - Fähigkeit meiner
> > > Klasse geben kann ....
> > >
> >
> > Du könntest Dir einen Ableitung der ArrayList erstellen,
> > die dann die GISPoint-Objekte aufnimmt.
> >
> > Hier mal ein Sample aus dem TimeTracker Kit:
> >
> > using System;
> > using System.Collections;
> >
> > namespace ASPNET.StarterKit.TimeTracker.BusinessLogicLayer
> > {
> >
> >
> > //*********************************************************************
> > //
> > // CategoriesCollection Class
> > //
> > // The CategoriesCollection Class inherits from ArrayList. It has
> > its own implemenation
> > // of Sort based on the sortable Category fields.
> > //
> >
> > //*********************************************************************
> >
> > public class CategoriesCollection : ArrayList
> > {
> > public enum CategoryFields
> > {
> > Abbreviation,
> > Duration,
> > InitValue,
> > Name
> > }
> >
> > public void Sort(CategoryFields sortField, bool isAscending)
> > {
> > switch (sortField)
> > {
> > case CategoryFields.Name:
> > base.Sort(new NameComparer());
> > break;
> > case CategoryFields.Abbreviation:
> > base.Sort(new
> > AbbreviationComparer());
> > break;
> > case CategoryFields.Duration:
> > base.Sort(new DurationComparer());
> > break;
> > }
> >
> > if (!isAscending) base.Reverse();
> > }
> >
> > private sealed class NameComparer : IComparer
> > {
> > public int Compare(object x, object y)
> > {
> > Category first = (Category) x;
> > Category second = (Category) y;
> > return first.Name.CompareTo(second.Name);
> > }
> > }
> >
> > private sealed class AbbreviationComparer : IComparer
> > {
> > public int Compare(object x, object y)
> > {
> > Category first = (Category) x;
> > Category second = (Category) y;
> > return
> > first.Abbreviation.CompareTo(second.Abbreviation);
> > }
> > }
> >
> > private sealed class DurationComparer : IComparer
> > {
> > public int Compare(object x, object y)
> > {
> > Category first = (Category) x;
> > Category second = (Category) y;
> > return
> > first.EstDuration.CompareTo(second.EstDuration);
> > }
> > }
> > }
> > }
> >
> >
> > Gruss
> >
> > Alex
> >
> > Kommt zur .NET Community Conference in Karlsruhe
> > http://www.dotnetcommunityconference.com
> >
> >
> > _______________________________________________
> > CSharp.net Mailingliste, Postings senden an:
> > CSharp.net@glengamoi.com
> > An-/Abmeldung und Suchfunktion unter:
> > http://www.glengamoi.com/mailman/listinfo/csharp.net
>
> _______________________________________________
> CSharp.net Mailingliste, Postings senden an:
> CSharp.net@glengamoi.com
> An-/Abmeldung und Suchfunktion unter:
> http://www.glengamoi.com/mailman/listinfo/csharp.net