Guest User

Guest User

  • Tech Writer
  • 357
  • 120.5k

Using input parameter with Enum value

Mar 17 2012 3:06 PM
Hi

Given the following code example

// Method declaration
private bool ValidRequest(RequestBase request, ResponseBase response, Validate validate)

// Condition statement
if ((Validate.ClientTag & validate) == Validate.ClientTag)

Validate is an Enum with a variable ClientTag that has a value of 0x0001 assigned.

Am I right in saying that given Validate.ClientTag is an Enum, the assignment operator cannot be used to Set the input parameter validate. As a result the & operator needs to be used instead?

In addition the expression (Validate.ClientTag & validate) has to be encapsulated into its own parenthesis within the if statement due to the mismatch of types ClientTag and bool?

Thanks

Answers (4)