/ Published in: C#

This snippet accepts a string which is assumed to be the string version of one of the members and returns an enum object with the respective member selected.*
*Thanks to user: mcbutterbuns for improving upon my version of this snippet
*Thanks to user: mcbutterbuns for improving upon my version of this snippet
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
public enum PayTypeList { Unknown, Hourly, Salary, } // Throws an ArgumentException if the string is found not to be one of the members of the enum (in this case, if you pass in a string "Weekly" instead of "Hourly", it will throw an ArgumentException)
Comments
