Read-only hashtable

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Raghu

    #1

    Read-only hashtable

    The HashTable object exposes IsReadOnly property from IDictionary interface
    (default is false). I have a hashtable that I want expose in a method call.
    However I do not want the user to remove or add any items to it. Is there a
    way to use this property so that user won't change the items in the
    collection. First of all, I have not even see how you set this property to
    true. Does any one know how to set this property to true?

    Thanks.
    Raghu/..


  • Bret Mulvey

    #2
    Re: Read-only hashtable


    "Raghu" <Raghu@nospamzz zqcsi.com> wrote in message
    news:#xRAoWhrDH A.1960@TK2MSFTN GP12.phx.gbl...[color=blue]
    > The HashTable object exposes IsReadOnly property from IDictionary[/color]
    interface[color=blue]
    > (default is false). I have a hashtable that I want expose in a method[/color]
    call.[color=blue]
    > However I do not want the user to remove or add any items to it. Is there[/color]
    a[color=blue]
    > way to use this property so that user won't change the items in the
    > collection. First of all, I have not even see how you set this property to
    > true. Does any one know how to set this property to true?
    >[/color]

    Hashtable always returns false for IsReadOnly because the Hashtable class
    doesn't provide any read-only functionality.

    IsReadOnly, Add(), Remove(), Item(), etc. are all virtual. You can override
    them to provide a read-only hash table and use that derived type as your
    method's return type.


    Comment

    Working...