IList implementation

G

Guest

Hi, how is possible to have a strong-typed implementation of Item property in
the same class as IList is implemented?

Default Public Property Item(ByVal index As Integer) As Object
Implements System.Collections.IList.Item
Get
Return Me(index)
End Get
Set(ByVal Value As Object)
Me(index) = CType(Value, Azienda)
End Set
End Property
Public Overridable Property Item(ByVal index As Integer) As Azienda
Get
Return DirectCast(coll(index), Azienda)
End Get
Set(ByVal Value As Azienda)
coll(index) = Value
CType(coll(index), Azienda).RowState = DataRowState.Modified
RaiseEvent ListChanged(Me, New
ListChangedEventArgs(ListChangedType.ItemChanged, index))
End Set
End Property

The code above give me this design time error:
'Public Default Property Item(index As Integer) As Object' and 'Public
Overridable Property Item(index As Integer) As Azienda' cannot overload each
other because they differ only by return types.

I know to make it in C# but not in VB.NET
Can anyone help me?
Thanks in advance.
 
A

alejandro lapeyre

Default Public Property Item(.....

Private IList_Item(... implements IList.Item

Best Regards,
Alejanro Lapeyre

"Mirko" <[email protected]> escribió en el mensaje
Hi, how is possible to have a strong-typed implementation of Item property
in
the same class as IList is implemented?

Default Public Property Item(ByVal index As Integer) As Object
Implements System.Collections.IList.Item
Get
Return Me(index)
End Get
Set(ByVal Value As Object)
Me(index) = CType(Value, Azienda)
End Set
End Property
Public Overridable Property Item(ByVal index As Integer) As Azienda
Get
Return DirectCast(coll(index), Azienda)
End Get
Set(ByVal Value As Azienda)
coll(index) = Value
CType(coll(index), Azienda).RowState = DataRowState.Modified
RaiseEvent ListChanged(Me, New
ListChangedEventArgs(ListChangedType.ItemChanged, index))
End Set
End Property

The code above give me this design time error:
'Public Default Property Item(index As Integer) As Object' and 'Public
Overridable Property Item(index As Integer) As Azienda' cannot overload each
other because they differ only by return types.

I know to make it in C# but not in VB.NET
Can anyone help me?
Thanks in advance.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top