Property

S

shapper

Hello,

I am trying to convert some of my old VB.NET code to C# using an
online tool but I am getting an error:

Default Public Overloads Property Item(ByVal index As Integer)
As Element
Get
Return TryCast(MyBase.BaseGet(index), Element)
End Get
Set(ByVal value As Element)
If MyBase.BaseGet(index) IsNot Nothing Then
MyBase.BaseRemoveAt(index)
End If
Me.BaseAdd(index, value)
End Set
End Property ' Item

Becomes:

public ConfigElement Item {
get { return base.BaseGet(index) as ConfigElement; }
set {
if (base.BaseGet(index) != null) {
base.BaseRemoveAt(index);
}
this.BaseAdd(index, value);
}
}

index disappears as input. Can't I use it?

Thanks,
Miguel
 
S

shapper

I am trying to convert some of my old VB.NET code to C# using an
online tool but I am getting an error:
      Default Public Overloads Property Item(ByVal index As Integer)
As Element
[...]
    public ConfigElement Item {
[...]
index disappears as input. Can't I use it?

Seehttp://msdn.microsoft.com/en-us/library/6x16t2tx.aspx

This is a class I created a long time ago but that inherits an ASP.NET
existing class ...

I can't just change this the way I want, right? I am a little bit
lost.

What I have is:

Public Class ElementCollection
Inherits ConfigurationElementCollection

Default Public Overloads Property Item(ByVal index As Integer)
As Element
Get
Return TryCast(MyBase.BaseGet(index), Element)
End Get
Set(ByVal value As Element)
If MyBase.BaseGet(index) IsNot Nothing Then
MyBase.BaseRemoveAt(index)
End If
Me.BaseAdd(index, value)
End Set
End Property

Protected Overloads Overrides Function CreateNewElement() As
ConfigurationElement
Return New Element()
End Function

Protected Overloads Overrides Function GetElementKey(ByVal
element As ConfigurationElement) As Object
Return DirectCast(element, Element).Name
End Function

End Class

It is a "Overloading" property ... I am lost.

Any idea?

Thanks,
Miguel
 

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