473,383 Members | 2,005 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

overriding enums

guy
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
Nov 21 '05 #1
3 3253
"guy" <gu*@discussions.microsoft.com> schrieb:
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 K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>

Nov 21 '05 #2
guy
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
"Herfried K. Wagner [MVP]" wrote:
"guy" <gu*@discussions.microsoft.com> schrieb:
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 K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>

Nov 21 '05 #3
"guy" <gu*@discussions.microsoft.com> schrieb:
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
///

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>

Nov 21 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
by: SpaceCowboy | last post by:
I recently got into a discussion with a co-worker about using enums across a dll interface. He wanted to use chars instead, argueing that depending on compiler settings the size of an enum could...
2
by: Faisal | last post by:
Can anyone tell me if it is possible to enumerate through all the Enums within a class . I have a class with many Enums and would like to accees the Enums through an array/collection etc. I can't...
27
by: Mark A. Gibbs | last post by:
i have been toying with the idea of making my enums smarter - ie, more in line with the rest of the language. i haven't tested it yet, but what i came up with is a template like this: template...
2
by: SpotNet | last post by:
Hello CSharpies, Can Enums in C# be UInt32 Types, and not just Int32 Types. I have a lot of constant declarations that are UInt32 that I want to put in Enums to ease the use of Intellisence. I...
4
by: Martin Pritchard | last post by:
Hi, I'm working on a project that historically contains around 40 enums. In the database various fields refer to the int values of these enums, but of course ref integrity is not enofrced and...
2
by: Faisal | last post by:
Can anyone tell me if it is possible to enumerate through all the Enums within a class . I have a class with many Enums and would like to accees the Enums through an array/collection etc. I can't...
18
by: JohnR | last post by:
From reading the documentation, this should be a relatively easy thing. I have an arraylist of custom class instances which I want to search with an"indexof" where I'm passing an instance if the...
2
by: Simon Elliott | last post by:
I have some legacy C++ code which requires some enums to be 1 or 2 bytes in size. I'd ideally like to be able to specify that a few carefully selected enums are a particular size. By default,...
11
by: Marc Gravell | last post by:
This one stumped me while refactoring some code to use generics... Suppose I declare an enum MyEnum {...} Is there a good reason why MyEnum doesn't implement IEquatable<MyEnum> ? Of course,...
4
by: Jon Slaughter | last post by:
is there a simple way to "step" through enums? I have a button that I want to click and have it "cycle" through a set of states defined by enums but the only way I can think of doing this...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.