I have run across some interesting items in the last couple days regarding Enums. I have used some of these techniques before, but never really understood them. I don't claim to understand them any more than I did now, but at least I found someone else talking about it! :)
I ran into an interesting scenario with this on the GridView control's RowState property which is of type DataControlRowState. DataControlRowState is an Enum with the various states that a row in the grid can be in. See this link for the information directly regarding this on MSDN. In the RowDataBound function I was using an IF statement to check if the state of the current row was in edit mode (Enum value of 4). If e.Row.RowState = DataControlRowState.Edit Then... Well, this worked great for "DataControlRowState.Normal" rows (Enum value of 0), but not so much for "DataControlRowState.Alternate" rows (Enum value of 1), because the RowState actually equaled 5 (which is a combination of Edit (4) and Alternate (1)). This is a problem because my IF only worked for Normal Rows. So the question was how do I test for Edit regardles of any of the other settings that might also be true at the time. You can find this in a couple of the articles above, but here is the actual IF statement that works! If (e.Row.RowState And DataControlRowState.Edit) = DataControlRowState.Edit Then...