How would you translate this?

  • Thread starter Thread starter B. Chernick
  • Start date Start date
B

B. Chernick

I've just been tasked to translate a C# project into VB (Dot Net 2.0). I am
somewhat familiar with C# but far from an expert.

I'd like a second opinion on this one.

The project uses CSLA 2.1.4. The project has a class that inherits from
ReadOnlyBase. ReadOnlyBase has a method declaration:
protected virtual void DataPortal_Fetch(object criteria)
{
throw new NotSupportedException(Resources.FetchNotSupportedException);
}

The child class has a declaration:
private void DataPortal_Fetch(Criteria criteria)
where Criteria is a local private class.

(I am aware that this declaration is taking advantage of C#'s case
sensitivity. VS appears to have no problem with this declaration.)

In the VB version of CSLA, the declaration is:
Protected Overridable Sub DataPortal_Fetch(ByVal criteria As Object)
Throw New NotSupportedException(My.Resources.FetchNotSupportedException)
End Sub

What I am uncertain of is how to translate the declaration of the inheriting
class DataPortan_Fetch declaration.

If I try to do a direct translation, taking into account lack of case
sensitivity:

Private Sub DataPortal_Fetch(ByVal criteria1 As Criteria)

I get a warning: sub 'DataPortal_Fetch' shadows an overridable method in the
base class 'ReadOnlyBase'. To override the base method, this method must be
declared 'Overrides'.

The alternative, which eliminates the warning would appear to be:
Protected Overrides Sub DataPortal_Fetch(ByVal criteria1 As Object)
I would then do a ctype within the sub when it becomes necessary to access
the properties of the class Criteria.

Which would be the more accurate method?
 
It does eliminate the warning. Thanks!

(Of course I'm still trying to understand the original intent of the C# code.)
 
B. Chernick said:
It does eliminate the warning. Thanks!

(Of course I'm still trying to understand the original intent of the C# code.)

That's the intent of the original code. You simply don't have to specify
with a keyword that you are overloading a method in C#.
 
Back
Top