overriding enums

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

what is the best way to simulate the following line of code

Public MustOverride Enum Test
....

I have a data access base class and am using an enumeration in each child
class to map onto the columns returned by a DataReader

I would like to ensure the enumeration is always present in the child
classes, but the above code wont compile

suggestions gratefully appreciated

guy
 
guy said:
what is the best way to simulate the following line of code

Public MustOverride Enum Test
...

I have a data access base class and am using
an enumeration in each child class to map onto the
columns returned by a DataReader

I would like to ensure the enumeration is always present
in the child classes, but the above code wont compile

Can you provide more detailled code? I am not able to understand what you
want to do. Are you talking about redefining the enum or a property of the
enum's type?
 
Herfried sorry for the confusion:)
I have a base class that handles data access and a number of child forms
that inherit from it.
In each child form I have an enumeration that maps to the column names
returned for that child class so for example in my Person class I have an enum

Private Enum ColumnNames
NAME
ADDRESS1
ADDRESS2
...
end enum

and in my Invoices class I have an enum

Private Enum ColumnNames
INVOICE_NO
GROSS
NET
...
end enum

for consitency I would like my base class to have as this would ensure the
enum has the same name in each child class

Private MustOverride Enum ColumnNames
....

but this is not allowed

cheers

guy
 
guy said:
In each child form I have an enumeration that maps
to the column names returned for that child class so
for example in my Person class I have an enum

Private Enum ColumnNames
NAME
ADDRESS1
ADDRESS2
...
end enum

and in my Invoices class I have an enum

Private Enum ColumnNames
INVOICE_NO
GROSS
NET
...
end enum

for consitency I would like my base class to have as this would ensure the
enum has the same name in each child class

\\\
Dim b As New Bar()
b.SelectColumn(Bar.ColumnNames.Column1)
Dim fb As New FooBar()
fb.SelectColumn(FooBar.ColumnNames.Column2)
..
..
..
Public Class Bar
Public Enum ColumnNames
Column1
End Enum

Public Sub SelectColumn( _
ByVal Column As ColumnNames _
)
MsgBox("'Bar': " & Column.ToString())
End Sub
End Class

Public Class FooBar
Inherits Bar

Public Shadows Enum ColumnNames
Column1
Column2
End Enum

Public Shadows Sub SelectColumn( _
ByVal Column As ColumnNames _
)
MsgBox("'FooBar': " & Column.ToString())
End Sub
End Class
///
 
Back
Top