Jump to content
Xtreme .Net Talk

Recommended Posts

  • Leaders
Posted

The IList interface provides the property Item(Index As Integer) As Object, which is read/write. Many classes that implement IList, however, have an Item property which is of a different type and read-only (System.Windows.Forms.Control.ControlCollection and System.Windows.Forms.ListView.ListViewItemCollection for example). If you cast one of these collections to IList, then you can access the property Item(Index As Integer) As Object, but otherwise this property does not show up in intellisense or the object browser.

 

I am making my own collection, which implements IList. How can I reproduce this?

 

[Edit]Also note that this also applies to other members of IList, such as Add, and Insert, not just Item.[/Edit]

[sIGPIC]e[/sIGPIC]
Posted

system.array class using lutz's decompiler

Private Function System.Collections.IList.Add(ByVal value As Object) As Integer Implements IList.Add
     Throw New NotSupportedException(Environment.GetResourceString("NotSupported_FixedSizeCollection"))
End Function

Private Sub System.Collections.IList.RemoveAt(ByVal index As Integer) Implements IList.RemoveAt
     Throw New NotSupportedException(Environment.GetResourceString("NotSupported_FixedSizeCollection"))
End Sub

  • Leaders
Posted
There we go. Thanks. It seems kinda obvious but I actually tried it. The code editor marked the line as having an error, and I assumed it was because I implemented a function privately when it was actually something else.
[sIGPIC]e[/sIGPIC]

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...