Created
July 12, 2017 07:34
-
-
Save igniuss/1fe307798aef1bf1a729168d39f9d1b7 to your computer and use it in GitHub Desktop.
Simple example of array accessor using enums
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MessageType { | |
public string[] array; | |
public enum MessageEnum { | |
Shutdown = 0, | |
Reboot = 1, | |
Softlock = 2 | |
} | |
public string this[MessageEnum val] { | |
get { | |
return array[(int)val]; | |
} | |
set { | |
array[(int)val] = value; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment