Comparing enumeration value

G

Guest

Hello,

I have a class with a property called Quality. The property is defined as:

Public ReadOnly Property Quality() As Qualities

Qualities is defined as

Public Enum Qualities As System.UInt32

Qualities enumerated values are GOOD = 0 and BAD = 1

If I try to compile a VB.NET 2003 app with the following comparison:

If myClass.Quality = Qualities.GOOD Then
' do something
End If

I get the compiler error shown below:

error BC30452: Operator '=' is not defined for types 'Qualities' and
'Integer'.

The Help description is:
***
You have attempted to use a binary operator to perform an operation that is
not valid for the two value-returning code elements involved.

To correct this error check the two elements and make sure they are
compatible.
***

The equivalent code works in C#.NET

if (myClass.Quality == Qualities.GOOD) { }

Any suggestions?
 
J

Jon Skeet [C# MVP]

HairlipDog58 said:
I have a class with a property called Quality. The property is defined as:

Public ReadOnly Property Quality() As Qualities

Qualities is defined as

Public Enum Qualities As System.UInt32

Qualities enumerated values are GOOD = 0 and BAD = 1

If I try to compile a VB.NET 2003 app with the following comparison:

If myClass.Quality = Qualities.GOOD Then
' do something
End If

I get the compiler error shown below:

error BC30452: Operator '=' is not defined for types 'Qualities' and
'Integer'.

Could you post a short but complete program which demonstrates the
problem?

See http://www.pobox.com/~skeet/csharp/complete.html for details of
what I mean by that.
 
M

Mattias Sjögren

If I try to compile a VB.NET 2003 app with the following comparison:

VB.NET 2003 (any version earlier than 8.0/2005) doesn't support
unsigned integers or enums based on them.


Mattias
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top