B
Bob Weiner
What I want to be able to do is create an indexer that can index into an
ArrayList filled with objects of my own type. I have the following class
structure:
----------------------------------------------
class PropertyList : ArrayList {
public enum SortOrder { }
public object this [string name] { // cannot figure this one
t }
public void Sort (SortOrder order) { ... base.Sort
(oPropertyListSort); ... }
class PropertyListSort : IComparer {
SortOrder order;
public SortOrder SortField { }
public int Compare (object x, object y)
}
}
class ADOProperty { }
----------------------------------------------
The PropertyList contains a bunch of ADOProperty objects. The Sort routine
can sort the objects based on 2 different fields. This routine works fine.
What I cannot do is figure out how to write the indexer so I can get the
object based on the value of the sorted field. It seems that I should
somehow be able to call this.BinarySearch inside of the indexer to find the
desired object but I cannot find a set of arguments that will not cause an
'System.InvalidOperationException'
Is there a better or more standard way to attack this problem. I can think
of more involved ways to go about achieving my goal but but this seems like
something that the ArrayList should be able to handle (and now I'm
stubborn).
Thanks,
bob
ArrayList filled with objects of my own type. I have the following class
structure:
----------------------------------------------
class PropertyList : ArrayList {
public enum SortOrder { }
public object this [string name] { // cannot figure this one
t }
public void Sort (SortOrder order) { ... base.Sort
(oPropertyListSort); ... }
class PropertyListSort : IComparer {
SortOrder order;
public SortOrder SortField { }
public int Compare (object x, object y)
}
}
class ADOProperty { }
----------------------------------------------
The PropertyList contains a bunch of ADOProperty objects. The Sort routine
can sort the objects based on 2 different fields. This routine works fine.
What I cannot do is figure out how to write the indexer so I can get the
object based on the value of the sorted field. It seems that I should
somehow be able to call this.BinarySearch inside of the indexer to find the
desired object but I cannot find a set of arguments that will not cause an
'System.InvalidOperationException'
Is there a better or more standard way to attack this problem. I can think
of more involved ways to go about achieving my goal but but this seems like
something that the ArrayList should be able to handle (and now I'm
stubborn).
Thanks,
bob