Is there any ObjectList class in c#? I mean, a class that can keep a list
with pointers to objects. I come from Delphi background and I'm trying to
translate a sample "observer pattern" demo to C#
(pseudo code. I hope you know what I mean)
class B
{
procedure ObservedChange{}
B{ A.AddObserver(self instance, this?) }
}
class A
{
type? List
procedure AddObserver(B b);
procedure Change;
{
for i=0 to List.Count {
List.Item.ObservedChange; //{??????}
}
The "equivalent" of an a Delphi TObjectList in .NET is the ArrayList. In
fact Delphi for .NET's TList is really an ArrayList. However, if you're
looking at building an observer, you might want to look at Multicast
Delegates. They are in fact an implementation of the observer pattern.
Ask a Question
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.