Jim Hunter:
Nick Gravelyn:If you accept an integer in place of that enumeration, what's to stop people from querying player 1874343's controller?
An exception would be thrown, just as it is if you do (PlayerIndex)1874343.
Correct, but the fact that it takes a PlayerIndex leads most people to look and use one of the four valid PlayerIndex values. There is input guidance by using an enumeration. With an integer, your only guidance is what the compiler allows you to input, which is horrible design in my opinion.
As for looping, you just do the normal for loop and cast:
I know you
can do that, but had believed this to be a bad practice, since there is no guarantee (since the values you are using in your for loop are not documented) that the library's author won't change the values in a later release, thus breaking your code. I'm probably just excessively paranoid. :)
That is a valid point. There are ways to use the Enum class to get at the values of an enumeration (granted that only works on the desktop CLR right now), but at least in this situation, I'd consider it fairly safe to use the loop. Of course you are totally correct that the values could change, but it's usually more likely that they will stay the same once released.