473,806 Members | 2,845 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 3277
"guy" <gu*@discussion s.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*@discussion s.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*@discussion s.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.ColumnN ames.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
9558
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 change and lead to memory corruption. I didn't see how this was possible. He claims that if a dll built for a program is built with different compiler settings than the launcher program, the enum size could change. The only way I could figure...
2
2083
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 seem to find an appropriate Reflection method to access Enums within a class I would like to loop through the Enums in the 'Foo' Class retrieve the Enums 'Car' and 'House Public Class Fo Public Enum Ca For Chevrole Toyot
27
2748
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 <typename Enum> class smart_enum { public: typedef Enum enum_type;
2
1796
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 have them in structs for now, I thought I'd ask. Would IntPtr Enums push the bounds of a stupid question? Regarding a post a bit further down by Tom; ' What would you like to change in C# and .NET?'
4
5594
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 when looking at the db we can't tell what the value in a field represents. The other problem is that our enums are currently all stored in a single class, which means that because of no visibility constraints the enums are often used out of context...
2
1999
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 seem to find an appropriate Reflection method to access Enums within a class Thanks! --- Posted using Wimdows.net Newsgroups - http://www.wimdows.net/newsgroups/
18
4754
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 class where only the "searched" property has a value. I expected to get the index into the arraylist where I could then get the entire class instance. However, the 'indexof' is never calling my overloaded, overrides Equals method. Here is the...
2
2885
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, g++ seems to create enums of 4 bytes in length, unless I use the -fshort-enums option. I don't much want to use this all or nothing approach in case it breaks library code etc, and there's no guarantee that other compilers have a comparable...
11
12562
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, I can cast a MyEnum instance down to the int / short whatever (since int implements IEquatable<int>), but I don't like doing that, as it feels a bit messy, and I am then propegating the things that know what the base represenation is...
4
3001
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 "properly" yet "ugly" is to test the state for each state. I know that enumes are not ordered but since they are "stored" as numbers they have an inherent ordering which can be used. I don't really care about the ordering though but just the ability to...
0
9719
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9597
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10366
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10371
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10110
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9187
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7649
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
1
4329
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3850
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.