Beginning C# - Part 12: Constants and Enumerations | Ray Wenderlich

In this episode, you'll learn how to use to constants and enumerations in your code to make it safer and easier to understand.


This is a companion discussion topic for the original entry at https://www.raywenderlich.com/3247-beginning-c/lessons/12

I think this solution of the challenge could be useful for beginners too:

public enum DayOfWeek {Monday=1, Tuesday, Wednesday, Thursday,Friday, Saturday,Sunday};
public DayOfWeek currentDay;

switch((int)currentDay)
{
case 1:
Debug.Log (“You can fall apart”);
break;
case 2:
case 3:
Debug.Log (“Break my heart”);
break;
case 4:
Debug.Log (" Doesn’t even start");
break;
case 5:
Debug.Log (“I’m in love”);
break;
case 6:
Debug.Log (“Wait”);
break;
case 7:
Debug.Log (“Always come too late”);
break;
}

1 Like

Nice job on that one!

Dear Mr. Moakley,

Hello there! I just wanted to take the time to thank you for the very obvious effort you put into these free video tutorials. Until I stumbled across this series, scripting was the one element of Unity that totally went over my head. Thank you for making programming in C# accessible and fun for even the least left brained people! Keep up the excellent work and cheers :smiley:

Best regards,
Fiona Barton

Great song :stuck_out_tongue: