Merging several of the other answers (mjv, pasta, Mike Hofer, R. Bemrose) together you will come up with the following code.
- Use a function to test if the staff ID is valid, that way you only need to change one place.
- An int array doesn't have a Contains method, so you will need to convert it to an IList (Unless using the extension methods provided in 3.0 in the System.Linq namespace).
As for the code:
if(!isStaffIDValid(staffid))
{
//do the req thing ..
}
...
Then in either the same class, or more preferably a global class use this code:
public static IList<int> notAllowedIDs = new int[] { 23, 24, 25, 26, 27, 29, 31 };
public static bool isStaffIDValid(int staffID)
{
return !notAllowedIDs.Contains(staffID);
}
This provides more maintainable code that can be easily updated.