Help with Translation from C# to VB.NET

A

AMerrell

Hello,

In C# I have seen subs overload each other that have the same signature. For example:

void IPostBackDataHandler.RaisePostDataChangedEvent()
{
((BasePostBackControl)this).RaisePostDataChangedEvent();
}

protected virtual void RaisePostDataChangedEvent()
{
}

To trasnlate this to VB.NET I came up with this:


Public Sub RaisePostDataChangedEvent() Implements IPostBackDataHandler.RaisePostDataChangedEvent
CType(Me, BasePostBackControl).RaisePostDataChangedEvent()
End Sub

Protected Overridable Sub RaisePostDataChangedEvent()
End Sub

Ofcourse I get the error that both have identical signatures. So, I rewrite them to this:

Public Overridable Sub RaisePostDataChangedEvent() Implements IPostBackDataHandler.RaisePostDataChangedEvent
End Sub

It clears up the Identical Signature problem but then the class that overrides this sub end up with different access level errors. And if I go with:

Protected Overridable Sub RaisePostDataChangedEvent()
End Sub

My IPostBackDataHandler implementation is in error. So my question is. How can I handle this in VB.NET?

Thanks for any help,

AM
 
M

Mattias Sjögren

My IPostBackDataHandler implementation is in error. So my question is. How can I handle this in VB.NET?

Implement IPostBackDataHandler.RaisePostDataChangedEvent under a
different name, that's what the C# code does.

Private Sub IPostBackDataHandler_RaisePostDataChangedEvent()
Implements IPostBackDataHandler.RaisePostDataChangedEvent
CType(Me, BasePostBackControl).RaisePostDataChangedEvent()
End Sub

Protected Overridable Sub RaisePostDataChangedEvent()
End Sub



Mattias
 

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