4
Answers

Using input parameter with Enum value

Guest User

Guest User

12y
2.7k
1
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)