Click here to Skip to main content
16,005,114 members
Home / Discussions / C#
   

C#

 
GeneralRe: managed DLL error with C# Pin
Heath Stewart22-Feb-05 13:10
protectorHeath Stewart22-Feb-05 13:10 
GeneralRe: managed DLL error with C# Pin
Heath Stewart22-Feb-05 13:06
protectorHeath Stewart22-Feb-05 13:06 
QuestionIs it possible??? Pin
students552 university21-Feb-05 8:27
students552 university21-Feb-05 8:27 
AnswerRe: Is it possible??? Pin
Heath Stewart21-Feb-05 12:27
protectorHeath Stewart21-Feb-05 12:27 
Questionhow to connect to Net without voilating security issues Pin
Samar Aarkotti21-Feb-05 7:34
Samar Aarkotti21-Feb-05 7:34 
AnswerRe: how to connect to Net without voilating security issues Pin
leppie21-Feb-05 11:12
leppie21-Feb-05 11:12 
GeneralGetting notification of alteration to a collection Pin
FocusedWolf21-Feb-05 7:08
FocusedWolf21-Feb-05 7:08 
GeneralRe: I need a collection thats threadsafe and doesn't inherit collectionbase Pin
Heath Stewart21-Feb-05 7:19
protectorHeath Stewart21-Feb-05 7:19 
You're subject and message content have nothing to do with each other. Which is it that you want? Some collections - like the ArrayList - expose a Synchronized method that you can get a thread-safe IList or ICollection (which IList inherits).

For your problem you need to realize that many classes don't use your class but rather the underlying IList or ICollection interface, meaning that your typed methods like int Add(MyObject obj) will not be called. When your class is cast to an IList or any other interface the implementation of those interface methods or properties is used - not yours.

If you inherit from CollectionBase, all you need to do is override the OnEventName methods and do what you need to, like perhaps even firing events if that's what you need, or instrumenting your class. If you look at the implementing of CollectionBase using ildasm.exe from the .NET Framework SDK or .NET Reflector you can search for online, you will see that OnInsertComplete is all that is called for IList.Add and IList.Insert when you use the List property instead of the InnerList property. The documentation for these properties even states that. If you want to fire your own events than use the InnerList property. The List property IS the IList implementation of your CollectionBase derivative, which will invoke those On* methods.

The documentation is rather clear about this, IMO, but you can always use utilities like .NET Reflector to see how these classes work internally.

This posting is provided "AS IS" with no warranties, and confers no rights.

Software Design Engineer
Developer Division Sustained Engineering
Microsoft

[My Articles] [My Blog]
GeneralRe: I need a collection thats threadsafe and doesn't inherit collectionbase Pin
FocusedWolf21-Feb-05 9:52
FocusedWolf21-Feb-05 9:52 
GeneralRe: I need a collection thats threadsafe and doesn't inherit collectionbase Pin
Heath Stewart21-Feb-05 12:03
protectorHeath Stewart21-Feb-05 12:03 
GeneralUserControl Pin
Exenten21-Feb-05 6:43
Exenten21-Feb-05 6:43 
GeneralRe: UserControl Pin
Dave Kreskowiak21-Feb-05 15:35
mveDave Kreskowiak21-Feb-05 15:35 
GeneralSorting in DataGrid Pin
Anonymous21-Feb-05 6:01
Anonymous21-Feb-05 6:01 
GeneralRe: Sorting in DataGrid Pin
Heath Stewart21-Feb-05 12:18
protectorHeath Stewart21-Feb-05 12:18 
GeneralRe: Sorting in DataGrid Pin
Anonymous21-Feb-05 17:25
Anonymous21-Feb-05 17:25 
Generaladding reference to cdoex on a remote server Pin
Member 169690721-Feb-05 5:16
Member 169690721-Feb-05 5:16 
GeneralRe: adding reference to cdoex on a remote server Pin
Heath Stewart21-Feb-05 12:11
protectorHeath Stewart21-Feb-05 12:11 
Generalpager dialer question Pin
daddion21-Feb-05 3:13
daddion21-Feb-05 3:13 
GeneralRe: pager dialer question Pin
Heath Stewart21-Feb-05 12:09
protectorHeath Stewart21-Feb-05 12:09 
GeneralFind Today’ Date Using Code Pin
Anonymous21-Feb-05 3:02
Anonymous21-Feb-05 3:02 
GeneralRe: Find Today’ Date Using Code Pin
Rob Graham21-Feb-05 3:16
Rob Graham21-Feb-05 3:16 
GeneralRe: Find Today’ Date Using Code Pin
Heath Stewart21-Feb-05 12:07
protectorHeath Stewart21-Feb-05 12:07 
GeneralRe: Find Today’ Date Using Code Pin
Sebastian Schneider23-Feb-05 1:43
Sebastian Schneider23-Feb-05 1:43 
GeneralRe: Find Today’ Date Using Code Pin
Heath Stewart23-Feb-05 7:42
protectorHeath Stewart23-Feb-05 7:42 
GeneralVowel count Pin
lindiwe21-Feb-05 1:55
lindiwe21-Feb-05 1:55 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.