All pastes #200252 Raw Edit

Unnamed

public text v1 · immutable
#200252 ·published 2006-10-13 01:35 UTC
rendered paste body
public class AddrBook
{
    // internal variable to hold the bookList
    private ArrayList bookList;

    // outsiders may access the list with the Book property
    public ArrayList Book
    {
        get { return bookList; }
        private set { bookList = value; }   // <-- if we provide a protected or
                                            // private setter then we can set it
                                            // using the property inside the class,
                                            // but the property would still only be
                                            // 'gettable' for ousiders.
    }

    public AddrBook(Addr addr)
    {
        Book = new ArrayList();
        Book.Add(addr);
    }


AddrBook ab = new AddrBook();
ab.Book.Add(addr);
ab.Book = new ArrayList();  // <-- WRONG!!!!