Would be nice to specify an incremenet or decremenet as an attribute in an
enum so I can for example have the following...
[Increment(2)]
enum SomeEnum
{
A = 0,
B, // 2
C, // 4
D /6
}
or even Powers of 2 for [Flags] and [Base(2)]
so I get...
[Flags]
[Base(2)]
enum SomeEnum
{
A = 0,
B, // 1
C, // 2
D /4
}
Since you are including other lazy coder features in 2.0, how about this
lazy feature too! 1 1609
<di********@dis cussion.microso ft.com> wrote in message
news:eT******** ******@TK2MSFTN GP11.phx.gbl... Would be nice to specify an incremenet or decremenet as an attribute in an enum so I can for example have the following...
[Increment(2)] enum SomeEnum { A = 0, B, // 2 C, // 4 D /6 }
How do you propose handling
[Increment(2)]
enum SomeEnum
{
A = 0,
B, //2
C, //4
D=5,
E, // 6, 7, or 8?
F=3,
G, // 5, 8,10, or 12?
} or even Powers of 2 for [Flags] and [Base(2)] so I get...
[Flags] [Base(2)] enum SomeEnum { A = 0, B, // 1 C, // 2 D /4 }
While this may have SOME merit, more so than the increment, it still has a
few problems. For one, you should extend the flags class to
FlagsAttribute( int base), not add a new attribute. But in cases like:
[Flags(2)]
enum SomeEnum
{
A = 0,
B, //1
C, //2
D=5, //
E, //what should this be, 4, 8?
F=3, //
G, // what about this one?
} Since you are including other lazy coder features in 2.0, how about this lazy feature too!
In the end, I think both of these features would make it ALOT harder to use
and understand enums, I don't see much point in them.
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Mr.Tickle |
last post by:
When setting the attribute on an enum, why should I have to specify
powers of 2 when the compiler should see this is a bitfield and set the
range accordingly, why should I have to do the work that the compiler can
do?
To me this is just asking for errors to be introduced by offloading this
responsibility onto the programmer.
Sure we should be able to override a value in the bitfield enum to allow
|
by: Merlin |
last post by:
I believe that interfaces are one of the more useful
design constructs available in C#. However, there's one
thing that I feel is missing in them. I propose that
interfaces be expanded to allow the specification of
constructors. Admittedly, this makes things a bit
confusing in that seeing constructors in an interface
seems to imply that the interface itself can be
instantiated. But I don't believe that it would be
significantly worse...
|
by: Matt |
last post by:
Hi,
Recently we had some code like this cause a failure:
MyEnum myEnum = (MyEnum) (int) dt;
i.e. reading an int out of the database and casting it into a
type-safe enum.
The thought behind this construct was to enforce type safety and
|
by: Andreas Huber |
last post by:
Hi there
Spending half an hour searching through the archive I haven't found a
rationale for the following behavior.
using System;
// note the missing Flags attribute
enum Color
{
|
by: Marc Scheuner [MVP ADSI] |
last post by:
Folks,
I was trying to achieve the following thing: I have a "structure" that
basically is a two-dimensional array of numeric values. Both
dimensions are handled by enumeration types in C#:
public enum Level = { low, medium, high };
public enum Foo = { bar, subbar, superbar };
Now my idea was to create a two-dimensional array using those enum's
| |
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...
|
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,...
|
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,...
|
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...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
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
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |