473,396 Members | 1,724 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,396 software developers and data experts.

enum annoyance...

I realize that C# is a strongly typed language, but as a C++ programmer converting to C# I find the requirement that I typecast my integer enum values to be particularly annoying. Does anyone else in the C# community think that the compiler should relax this a bit

// example, define an enum that derives from an int type

public enum Fruit : in

Apple = 1
Banana = 2
Cherry = 3
Date = 4
// etc..
// later in my code I want to use the fruit enum to index some arrays

stock[ Fruit.Apple ] += ( received[ Fruit.Apple ] - shipped[ Fruit.Apple ] )

// I have already told the compiler in my enum declaration that a Fruit is an integer, so why
// do I have to do it this way

stock[ (int) Fruit.Apple ] += ( received[ (int) Fruit.Apple ] - shipped[ (int) Fruit.Apple ] )

// just seems like a lot of unnecessary typing to me...

Sorry to gripe, but this is one place I can post it where somebody who can actually do something about it might see it :-

-- Steve
Jul 21 '05 #1
16 1680
sloughin <an*******@discussions.microsoft.com> wrote:
I realize that C# is a strongly typed language, but as a C++
programmer converting to C# I find the requirement that I typecast my
integer enum values to be particularly annoying. Does anyone else in
the C# community think that the compiler should relax this a bit?
Personally, no.
// example, define an enum that derives from an int type:

public enum Fruit : int
{
Apple = 1,
Banana = 2,
Cherry = 3,
Date = 4,
// etc...
}

// later in my code I want to use the fruit enum to index some arrays:

stock[ Fruit.Apple ] += ( received[ Fruit.Apple ] - shipped[ Fruit.Apple ] );

// I have already told the compiler in my enum declaration that a
// Fruit is an integer, so why do I have to do it this way:
A Fruit *isn't* an integer - it's a Fruit. It's just that you've told
the compiler there's a relationship between Fruits and ints, namely
that any Fruit can be represented as an int.
stock[ (int) Fruit.Apple ] += ( received[ (int) Fruit.Apple ] -
shipped[ (int) Fruit.Apple ] );

// just seems like a lot of unnecessary typing to me...

Sorry to gripe, but this is one place I can post it where somebody
who can actually do something about it might see it :-)


And where I for one hope no-one will do anything about it :)

You could always write a FruitCollection which used Fruit as the
indexer - but Fruit *isn't* the parameter for any array indexer, and I
don't want to accidentally use a Fruit where I really mean an int.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Jul 21 '05 #2
sloughin <an*******@discussions.microsoft.com> wrote:
I realize that C# is a strongly typed language, but as a C++
programmer converting to C# I find the requirement that I typecast my
integer enum values to be particularly annoying. Does anyone else in
the C# community think that the compiler should relax this a bit?
Personally, no.
// example, define an enum that derives from an int type:

public enum Fruit : int
{
Apple = 1,
Banana = 2,
Cherry = 3,
Date = 4,
// etc...
}

// later in my code I want to use the fruit enum to index some arrays:

stock[ Fruit.Apple ] += ( received[ Fruit.Apple ] - shipped[ Fruit.Apple ] );

// I have already told the compiler in my enum declaration that a
// Fruit is an integer, so why do I have to do it this way:
A Fruit *isn't* an integer - it's a Fruit. It's just that you've told
the compiler there's a relationship between Fruits and ints, namely
that any Fruit can be represented as an int.
stock[ (int) Fruit.Apple ] += ( received[ (int) Fruit.Apple ] -
shipped[ (int) Fruit.Apple ] );

// just seems like a lot of unnecessary typing to me...

Sorry to gripe, but this is one place I can post it where somebody
who can actually do something about it might see it :-)


And where I for one hope no-one will do anything about it :)

You could always write a FruitCollection which used Fruit as the
indexer - but Fruit *isn't* the parameter for any array indexer, and I
don't want to accidentally use a Fruit where I really mean an int.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Jul 21 '05 #3
a Fruit is a Fruit.

It may be represented as an integer but it is a Fruit.

I don't think that this rule should be relaxed. The cast is very helpful, it
shows that you are doing something that depends on the internal
representation of your Fruit enum. All the rest (stuff that does not need
casting) is "safe" stuff that does not assume anything special about the
representation of your enum.

Bruno

"sloughin" <an*******@discussions.microsoft.com> a écrit dans le message de
news:01**********************************@microsof t.com...
I realize that C# is a strongly typed language, but as a C++ programmer converting to C# I find the requirement that I typecast my integer enum
values to be particularly annoying. Does anyone else in the C# community
think that the compiler should relax this a bit?
// example, define an enum that derives from an int type:

public enum Fruit : int
{
Apple = 1,
Banana = 2,
Cherry = 3,
Date = 4,
// etc...
}

// later in my code I want to use the fruit enum to index some arrays:

stock[ Fruit.Apple ] += ( received[ Fruit.Apple ] - shipped[ Fruit.Apple ] );
// I have already told the compiler in my enum declaration that a Fruit is an integer, so why // do I have to do it this way:

stock[ (int) Fruit.Apple ] += ( received[ (int) Fruit.Apple ] - shipped[ (int) Fruit.Apple ] );
// just seems like a lot of unnecessary typing to me...

Sorry to gripe, but this is one place I can post it where somebody who can actually do something about it might see it :-)
-- Steve

Jul 21 '05 #4
a Fruit is a Fruit.

It may be represented as an integer but it is a Fruit.

I don't think that this rule should be relaxed. The cast is very helpful, it
shows that you are doing something that depends on the internal
representation of your Fruit enum. All the rest (stuff that does not need
casting) is "safe" stuff that does not assume anything special about the
representation of your enum.

Bruno

"sloughin" <an*******@discussions.microsoft.com> a écrit dans le message de
news:01**********************************@microsof t.com...
I realize that C# is a strongly typed language, but as a C++ programmer converting to C# I find the requirement that I typecast my integer enum
values to be particularly annoying. Does anyone else in the C# community
think that the compiler should relax this a bit?
// example, define an enum that derives from an int type:

public enum Fruit : int
{
Apple = 1,
Banana = 2,
Cherry = 3,
Date = 4,
// etc...
}

// later in my code I want to use the fruit enum to index some arrays:

stock[ Fruit.Apple ] += ( received[ Fruit.Apple ] - shipped[ Fruit.Apple ] );
// I have already told the compiler in my enum declaration that a Fruit is an integer, so why // do I have to do it this way:

stock[ (int) Fruit.Apple ] += ( received[ (int) Fruit.Apple ] - shipped[ (int) Fruit.Apple ] );
// just seems like a lot of unnecessary typing to me...

Sorry to gripe, but this is one place I can post it where somebody who can actually do something about it might see it :-)
-- Steve

Jul 21 '05 #5
sloughin wrote:
I realize that C# is a strongly typed language, but as a C++
programmer converting to C# I find the requirement that I typecast my
integer enum values to be particularly annoying. Does anyone else in
the C# community think that the compiler should relax this a bit?

// example, define an enum that derives from an int type:

public enum Fruit : int
{
Apple = 1,
Banana = 2,
Cherry = 3,
Date = 4,
// etc...
}

// later in my code I want to use the fruit enum to index some arrays:

stock[ Fruit.Apple ] += ( received[ Fruit.Apple ] - shipped[
Fruit.Apple ] );

// I have already told the compiler in my enum declaration that a
Fruit is an integer, so why // do I have to do it this way:

stock[ (int) Fruit.Apple ] += ( received[ (int) Fruit.Apple ] -
shipped[ (int) Fruit.Apple ] );

// just seems like a lot of unnecessary typing to me...

Sorry to gripe, but this is one place I can post it where somebody
who can actually do something about it might see it :-)


Unlike Jon and Bruno, I agree with you. By default the underlying type for
enum is int. However you can specify any integral type except char as the
underlying type for enum. I think the compiler should be smart enough to
know what the underlying type is for the enum and not force you to cast.
--
Tom Porterfield
MS-MVP MCE
http://support.telop.org

Please post all follow-ups to the newsgroup only.

Jul 21 '05 #6
sloughin wrote:
I realize that C# is a strongly typed language, but as a C++
programmer converting to C# I find the requirement that I typecast my
integer enum values to be particularly annoying. Does anyone else in
the C# community think that the compiler should relax this a bit?

// example, define an enum that derives from an int type:

public enum Fruit : int
{
Apple = 1,
Banana = 2,
Cherry = 3,
Date = 4,
// etc...
}

// later in my code I want to use the fruit enum to index some arrays:

stock[ Fruit.Apple ] += ( received[ Fruit.Apple ] - shipped[
Fruit.Apple ] );

// I have already told the compiler in my enum declaration that a
Fruit is an integer, so why // do I have to do it this way:

stock[ (int) Fruit.Apple ] += ( received[ (int) Fruit.Apple ] -
shipped[ (int) Fruit.Apple ] );

// just seems like a lot of unnecessary typing to me...

Sorry to gripe, but this is one place I can post it where somebody
who can actually do something about it might see it :-)


Unlike Jon and Bruno, I agree with you. By default the underlying type for
enum is int. However you can specify any integral type except char as the
underlying type for enum. I think the compiler should be smart enough to
know what the underlying type is for the enum and not force you to cast.
--
Tom Porterfield
MS-MVP MCE
http://support.telop.org

Please post all follow-ups to the newsgroup only.

Jul 21 '05 #7
Hi Tom

I don't think it is lack of smartness on the part of the compiler that is
the problem. The compiler is being quite smart enough when it declares that
you cannot set a fruit to an int. The fact that a fruit is represented
internally by an int is purely incidental. Externally, fruit is a set which
contains apple, orange, pear, etc. Unless you tell the compiler, explicitly,
that it can interpret 4 as a fruit then it should quite rightly get upset.

Charles
"Tom Porterfield" <tp******@mvps.org> wrote in message
news:%2******************@TK2MSFTNGP10.phx.gbl...
sloughin wrote:
I realize that C# is a strongly typed language, but as a C++
programmer converting to C# I find the requirement that I typecast my
integer enum values to be particularly annoying. Does anyone else in
the C# community think that the compiler should relax this a bit?

// example, define an enum that derives from an int type:

public enum Fruit : int
{
Apple = 1,
Banana = 2,
Cherry = 3,
Date = 4,
// etc...
}

// later in my code I want to use the fruit enum to index some arrays:

stock[ Fruit.Apple ] += ( received[ Fruit.Apple ] - shipped[
Fruit.Apple ] );

// I have already told the compiler in my enum declaration that a
Fruit is an integer, so why // do I have to do it this way:

stock[ (int) Fruit.Apple ] += ( received[ (int) Fruit.Apple ] -
shipped[ (int) Fruit.Apple ] );

// just seems like a lot of unnecessary typing to me...

Sorry to gripe, but this is one place I can post it where somebody
who can actually do something about it might see it :-)
Unlike Jon and Bruno, I agree with you. By default the underlying type

for enum is int. However you can specify any integral type except char as the
underlying type for enum. I think the compiler should be smart enough to
know what the underlying type is for the enum and not force you to cast.
--
Tom Porterfield
MS-MVP MCE
http://support.telop.org

Please post all follow-ups to the newsgroup only.

Jul 21 '05 #8
Hi Tom

I don't think it is lack of smartness on the part of the compiler that is
the problem. The compiler is being quite smart enough when it declares that
you cannot set a fruit to an int. The fact that a fruit is represented
internally by an int is purely incidental. Externally, fruit is a set which
contains apple, orange, pear, etc. Unless you tell the compiler, explicitly,
that it can interpret 4 as a fruit then it should quite rightly get upset.

Charles
"Tom Porterfield" <tp******@mvps.org> wrote in message
news:%2******************@TK2MSFTNGP10.phx.gbl...
sloughin wrote:
I realize that C# is a strongly typed language, but as a C++
programmer converting to C# I find the requirement that I typecast my
integer enum values to be particularly annoying. Does anyone else in
the C# community think that the compiler should relax this a bit?

// example, define an enum that derives from an int type:

public enum Fruit : int
{
Apple = 1,
Banana = 2,
Cherry = 3,
Date = 4,
// etc...
}

// later in my code I want to use the fruit enum to index some arrays:

stock[ Fruit.Apple ] += ( received[ Fruit.Apple ] - shipped[
Fruit.Apple ] );

// I have already told the compiler in my enum declaration that a
Fruit is an integer, so why // do I have to do it this way:

stock[ (int) Fruit.Apple ] += ( received[ (int) Fruit.Apple ] -
shipped[ (int) Fruit.Apple ] );

// just seems like a lot of unnecessary typing to me...

Sorry to gripe, but this is one place I can post it where somebody
who can actually do something about it might see it :-)
Unlike Jon and Bruno, I agree with you. By default the underlying type

for enum is int. However you can specify any integral type except char as the
underlying type for enum. I think the compiler should be smart enough to
know what the underlying type is for the enum and not force you to cast.
--
Tom Porterfield
MS-MVP MCE
http://support.telop.org

Please post all follow-ups to the newsgroup only.

Jul 21 '05 #9
Charles Law wrote:
Hi Tom

I don't think it is lack of smartness on the part of the compiler
that is the problem. The compiler is being quite smart enough when it
declares that you cannot set a fruit to an int. The fact that a fruit
is represented internally by an int is purely incidental. Externally,
fruit is a set which contains apple, orange, pear, etc. Unless you
tell the compiler, explicitly, that it can interpret 4 as a fruit
then it should quite rightly get upset.


I disagree that the fact that the underlying data type for Fruit is int is
purely incidental. I could specify some other integral type as the
underlying data type if it suited my needs. If the underlying type of Fruit
is int, and Fruit.Date is given a value of 4, then why shouldn't the
compiler be able to understand that Fruit.Date and 4 are equivalent without
the developer having to explicitly cast (int)Fruit.Date? The cast is
explicitly telling the compiler something that is implicitly known.

I understand the fundamentals of why the cast is required, I just disagree
that the behavior is the correct behavior.
--
Tom Porterfield
MS-MVP MCE
http://support.telop.org

Please post all follow-ups to the newsgroup only.

Jul 21 '05 #10
Charles Law wrote:
Hi Tom

I don't think it is lack of smartness on the part of the compiler
that is the problem. The compiler is being quite smart enough when it
declares that you cannot set a fruit to an int. The fact that a fruit
is represented internally by an int is purely incidental. Externally,
fruit is a set which contains apple, orange, pear, etc. Unless you
tell the compiler, explicitly, that it can interpret 4 as a fruit
then it should quite rightly get upset.


I disagree that the fact that the underlying data type for Fruit is int is
purely incidental. I could specify some other integral type as the
underlying data type if it suited my needs. If the underlying type of Fruit
is int, and Fruit.Date is given a value of 4, then why shouldn't the
compiler be able to understand that Fruit.Date and 4 are equivalent without
the developer having to explicitly cast (int)Fruit.Date? The cast is
explicitly telling the compiler something that is implicitly known.

I understand the fundamentals of why the cast is required, I just disagree
that the behavior is the correct behavior.
--
Tom Porterfield
MS-MVP MCE
http://support.telop.org

Please post all follow-ups to the newsgroup only.

Jul 21 '05 #11
I think we may end up agreeing to disagree ;-), but ...

The point of abstraction is that internal and external representation are
decoupled, and therefore, by definition, Fruit.Date and 4 are _not_
equivalent. The compiler is really being generous in allowing the assignment
to take place even with the cast.

Furthermore, are Fruit.Date and 4.0 equivalent? If you assign a double in
place of a Fruit.Date, should the compiler first attempt to convert the
double to an int and then make the assignment?

I'm currently with Jon and Bruno on this one.

Charles
"Tom Porterfield" <tp******@mvps.org> wrote in message
news:ur**************@TK2MSFTNGP09.phx.gbl...
Charles Law wrote:
Hi Tom

I don't think it is lack of smartness on the part of the compiler
that is the problem. The compiler is being quite smart enough when it
declares that you cannot set a fruit to an int. The fact that a fruit
is represented internally by an int is purely incidental. Externally,
fruit is a set which contains apple, orange, pear, etc. Unless you
tell the compiler, explicitly, that it can interpret 4 as a fruit
then it should quite rightly get upset.
I disagree that the fact that the underlying data type for Fruit is int is
purely incidental. I could specify some other integral type as the
underlying data type if it suited my needs. If the underlying type of

Fruit is int, and Fruit.Date is given a value of 4, then why shouldn't the
compiler be able to understand that Fruit.Date and 4 are equivalent without the developer having to explicitly cast (int)Fruit.Date? The cast is
explicitly telling the compiler something that is implicitly known.

I understand the fundamentals of why the cast is required, I just disagree
that the behavior is the correct behavior.
--
Tom Porterfield
MS-MVP MCE
http://support.telop.org

Please post all follow-ups to the newsgroup only.

Jul 21 '05 #12
I think we may end up agreeing to disagree ;-), but ...

The point of abstraction is that internal and external representation are
decoupled, and therefore, by definition, Fruit.Date and 4 are _not_
equivalent. The compiler is really being generous in allowing the assignment
to take place even with the cast.

Furthermore, are Fruit.Date and 4.0 equivalent? If you assign a double in
place of a Fruit.Date, should the compiler first attempt to convert the
double to an int and then make the assignment?

I'm currently with Jon and Bruno on this one.

Charles
"Tom Porterfield" <tp******@mvps.org> wrote in message
news:ur**************@TK2MSFTNGP09.phx.gbl...
Charles Law wrote:
Hi Tom

I don't think it is lack of smartness on the part of the compiler
that is the problem. The compiler is being quite smart enough when it
declares that you cannot set a fruit to an int. The fact that a fruit
is represented internally by an int is purely incidental. Externally,
fruit is a set which contains apple, orange, pear, etc. Unless you
tell the compiler, explicitly, that it can interpret 4 as a fruit
then it should quite rightly get upset.
I disagree that the fact that the underlying data type for Fruit is int is
purely incidental. I could specify some other integral type as the
underlying data type if it suited my needs. If the underlying type of

Fruit is int, and Fruit.Date is given a value of 4, then why shouldn't the
compiler be able to understand that Fruit.Date and 4 are equivalent without the developer having to explicitly cast (int)Fruit.Date? The cast is
explicitly telling the compiler something that is implicitly known.

I understand the fundamentals of why the cast is required, I just disagree
that the behavior is the correct behavior.
--
Tom Porterfield
MS-MVP MCE
http://support.telop.org

Please post all follow-ups to the newsgroup only.

Jul 21 '05 #13
I agree. Fruit.Date and 4 are not equivalent. Fruit.Date has lots of
calories and 4 is a square number. And I am very happy that the compiler can
make this difference and give me an error if I use one instead of the other.
Relaxing this rule would basically mean that you start giving up on the
distinction between types and their representation.

Bruno.

"Charles Law" <bl***@nowhere.com> a écrit dans le message de
news:uw****************@TK2MSFTNGP09.phx.gbl...
I think we may end up agreeing to disagree ;-), but ...

The point of abstraction is that internal and external representation are
decoupled, and therefore, by definition, Fruit.Date and 4 are _not_
equivalent. The compiler is really being generous in allowing the assignment to take place even with the cast.

Furthermore, are Fruit.Date and 4.0 equivalent? If you assign a double in
place of a Fruit.Date, should the compiler first attempt to convert the
double to an int and then make the assignment?

I'm currently with Jon and Bruno on this one.

Charles
"Tom Porterfield" <tp******@mvps.org> wrote in message
news:ur**************@TK2MSFTNGP09.phx.gbl...
Charles Law wrote:
Hi Tom

I don't think it is lack of smartness on the part of the compiler
that is the problem. The compiler is being quite smart enough when it
declares that you cannot set a fruit to an int. The fact that a fruit
is represented internally by an int is purely incidental. Externally,
fruit is a set which contains apple, orange, pear, etc. Unless you
tell the compiler, explicitly, that it can interpret 4 as a fruit
then it should quite rightly get upset.


I disagree that the fact that the underlying data type for Fruit is int is purely incidental. I could specify some other integral type as the
underlying data type if it suited my needs. If the underlying type of

Fruit
is int, and Fruit.Date is given a value of 4, then why shouldn't the
compiler be able to understand that Fruit.Date and 4 are equivalent

without
the developer having to explicitly cast (int)Fruit.Date? The cast is
explicitly telling the compiler something that is implicitly known.

I understand the fundamentals of why the cast is required, I just disagree that the behavior is the correct behavior.
--
Tom Porterfield
MS-MVP MCE
http://support.telop.org

Please post all follow-ups to the newsgroup only.


Jul 21 '05 #14
I agree. Fruit.Date and 4 are not equivalent. Fruit.Date has lots of
calories and 4 is a square number. And I am very happy that the compiler can
make this difference and give me an error if I use one instead of the other.
Relaxing this rule would basically mean that you start giving up on the
distinction between types and their representation.

Bruno.

"Charles Law" <bl***@nowhere.com> a écrit dans le message de
news:uw****************@TK2MSFTNGP09.phx.gbl...
I think we may end up agreeing to disagree ;-), but ...

The point of abstraction is that internal and external representation are
decoupled, and therefore, by definition, Fruit.Date and 4 are _not_
equivalent. The compiler is really being generous in allowing the assignment to take place even with the cast.

Furthermore, are Fruit.Date and 4.0 equivalent? If you assign a double in
place of a Fruit.Date, should the compiler first attempt to convert the
double to an int and then make the assignment?

I'm currently with Jon and Bruno on this one.

Charles
"Tom Porterfield" <tp******@mvps.org> wrote in message
news:ur**************@TK2MSFTNGP09.phx.gbl...
Charles Law wrote:
Hi Tom

I don't think it is lack of smartness on the part of the compiler
that is the problem. The compiler is being quite smart enough when it
declares that you cannot set a fruit to an int. The fact that a fruit
is represented internally by an int is purely incidental. Externally,
fruit is a set which contains apple, orange, pear, etc. Unless you
tell the compiler, explicitly, that it can interpret 4 as a fruit
then it should quite rightly get upset.


I disagree that the fact that the underlying data type for Fruit is int is purely incidental. I could specify some other integral type as the
underlying data type if it suited my needs. If the underlying type of

Fruit
is int, and Fruit.Date is given a value of 4, then why shouldn't the
compiler be able to understand that Fruit.Date and 4 are equivalent

without
the developer having to explicitly cast (int)Fruit.Date? The cast is
explicitly telling the compiler something that is implicitly known.

I understand the fundamentals of why the cast is required, I just disagree that the behavior is the correct behavior.
--
Tom Porterfield
MS-MVP MCE
http://support.telop.org

Please post all follow-ups to the newsgroup only.


Jul 21 '05 #15
Original posting seemed to got lost, I apologize if this response gets
duped.
I understand the fundamentals of why the cast is required, I just disagree
that the behavior is the correct behavior.


The C# spec states that an explicit cast is needed to go from the enum to
its underlying type and from the underlying type to the enum. So it is the
correct and intended behavior.

The CLI spec states the explicit casts are not needed so it seems the cast
is enforced by C# language compiler itself.

Interesting thing though, the C# spec says the following statement is legal,
even if none of the enum fields are defined as 0:
Fruit F=0;
Low and behold it compiles, but the following does not without an explicit
cast:
Fruit F=1;

Any ideas why spec allows this?


Jul 21 '05 #16
Original posting seemed to got lost, I apologize if this response gets
duped.
I understand the fundamentals of why the cast is required, I just disagree
that the behavior is the correct behavior.


The C# spec states that an explicit cast is needed to go from the enum to
its underlying type and from the underlying type to the enum. So it is the
correct and intended behavior.

The CLI spec states the explicit casts are not needed so it seems the cast
is enforced by C# language compiler itself.

Interesting thing though, the C# spec says the following statement is legal,
even if none of the enum fields are defined as 0:
Fruit F=0;
Low and behold it compiles, but the following does not without an explicit
cast:
Fruit F=1;

Any ideas why spec allows this?


Jul 21 '05 #17

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

Similar topics

21
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 {
8
by: SteveK | last post by:
I'm getting the error: "Cannot implicitly convert type 'MovesDBMigrate.MotionNameElementTypes' to 'int'" for this line of code: m_nameElementTableNames = "Tbl_NameCharacters"; Of course if...
31
by: Michael C | last post by:
If a class inherits from another class, say Form inherits from control, then I can assign the Form to a variable of type Control without needing an explicit conversion, eg Form1 f = new Form1();...
13
by: Don | last post by:
How do I get an Enum's type using only the Enum name? e.g. Dim enumType as System.Type Dim enumName as String = "MyEnum" enumType = ???(enumName)
1
by: Ilyan | last post by:
Is there any way of sorting items in Enum? For example, let's take this declaration: Enum SecurityLevel IllegalEntry = -1 MinimumSecurity = 0 MaximumSecurity = 1 End Enum When I type...
16
by: sloughin | last post by:
I realize that C# is a strongly typed language, but as a C++ programmer converting to C# I find the requirement that I typecast my integer enum values to be particularly annoying. Does anyone else...
1
by: Randy | last post by:
Hi, I downloaded and tried the ENUM++ code from CUJ http://www.cuj.com/documents/s=8470/cujboost0306besser/ but can't even get it to compile (see following). I have also downloaded and...
34
by: Steven Nagy | last post by:
So I was needing some extra power from my enums and implemented the typesafe enum pattern. And it got me to thinking... why should I EVER use standard enums? There's now a nice little code...
0
by: tony_in_da_uk | last post by:
*** I posted this on comp.lang.c++.moderated a couple days ago, and got a near-flippant response from someone who clearly didn't take the time to consider the import. I replied, and it's still not...
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...
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...
0
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,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...
0
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...
0
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,...

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.