# ? operator

This topic is 1474 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hello,

I am trying to understand the the XNA gamestate sample. Everything looks good except for one strange C# syntax that I have not seen before. It has to do with the ? operator. I am familiar with the conditional ? operator which can be used like this

(condition) ? statement if true : statement if false;


The code in the sample is

public PlayerIndex? ControllingPlayer
{
get { return controllingPlayer; }
internal set { controllingPlayer = value; }
}

PlayerIndex? controllingPlayer;


where the PlayerIndex is an enum. The rest of the code also uses the PlayerIndex with a "?" at the end. What does the "?" operator do in this case?