In the for loop video you use the + operator on KeyCode.Alpha1.
i.e. KeyCode.Alpha1 + index
KeyCode.Alpha1 is an object though, so I assume that this is overloading the + operator and the operation is defined within whatever class KeyCode.Alpha1 is an instance of.
That’s an interesting question which I cannot answer. I skimmed the Enum class in C# and it does not seem to provide any information on the + operator. Maybe I missed the part.
Last but not least, please hover your mouse over KeyCode in Visual studio, press down the ctrl key on your keyboard and click on KeyCode. A list should appear.
I’ve just had a play around with some code after reading the stack overflow post you linked. I’m convinced now that it’s an enum.
For example you can do…
enum Day {Monday, Tuesday}
public class MyClass
{
static public void Main()
{
Console.WriteLine(Day.Monday + 1);
}
}
This would output Tuesday
Edit: Just to be clear to anyone reading this, because I know others have been confused too. The reason you can do the operation KeyCode.Alpha1 + 1 is because KeyCode is a variable of type enum.