Hi, just wondering if it is possible to have a collections base class send an event to the collection. Not worded well but heres an example.
Class Tree
Property color
Property species
Class TreeCollection
property ColorCount
property SpeciesCount
This is very basic but what I want is if the color of a tree changes an event is fired that the collection sees to reset its count of trees with a certain color.
Hope this is clear enough
Regards

Collection events
Sontiago
Nothing wrong with asking for more help if what has been provided is something you cant use. I might suggest however that you take a little time and try to become "multi-lingual"; in .NET, the languages are so similar that it is pretty easy to pick up a new language once you have already learned one, and it can be a great advantage.
Here's the VB.NET equivalent:
Class Tree
Public ReadOnly Collection As TreeCollection
End Class
Class TreeCollection
Inherits List(Of Tree)
End Class
Note: I translated this by sight, and I havent used VB in a while, so I apologize if there are any egregious syntax errors. But that should at least get you started.
Fyodor Golos
MisterT006
ArnieM
Hi!
Add to Tree reference to the collection it is in. If Tree changed, it can call collection for update. This is better than events, because events require to attach/detach events and internal implementation require much more resources (memory & CPU).
class Tree
{
}
class TreeCollection : List<Tree>
{
}
cmsturg
chrisoldfield
The problem I had with the above method initially is that my Collection class used the "Implements System.Collections.CollectionBase", changeing to "List (of Tree)" means re-learning how to interact with my collection. I lost access the item property of the Collection. I'll keep bashing away at your example and make it work.
Kathleen Koclanes
It appears that everytime I create a tree instance i create a new intance of collection which does not work, a circular reference occured, probably in my attempt to convert to VB.
This is a request that will probably get "blasted" by C#'ers but could you possibly give example in VB.Net
Regards