Re: Ownership and dispose

Tech-Archive recommends: Fix windows errors by optimizing your registry

From: Christian Heide Damm (chrishd_at_microsoft.com)
Date: 07/29/04


Date: Thu, 29 Jul 2004 13:18:20 +0200

It "always" just keeps a reference to the original object.

Christian

---
"Dominic" <dominicsmith501@hotmail.com> wrote in message
news:514ecc2b.0407281519.7792c39b@posting.google.com...
> This is going to sound like a newbie question, but I have done a fair
> bit of C++. I'm just new to C# and .NET. I am trying to work out how
> ownership and calls to dispose are commonly used (and what assumptions
> people tend to make).
>
> Here is an example, suppose I am writing my own MyListControl. I have
> a class Item which represents an item in the list (text, color, image
> index etc). There is a method of MyListControl.AddItem(Item item)
> which adds an item to the list control.
>
> Would you expect the control to keep a reference to item or make a
> copy of item? Or would you just think either case to be equally likely
> and verge on the safe side (assume the control keeps a reference).
>
> This is important to the caller, because if a reference is kept, the
> caller shouldn't modify andf re-use the object, or dispose it.
>
> Dom


Relevant Pages