fork download
  1. using System;
  2. using System.Linq;
  3.  
  4. public class Test
  5. {
  6. public static void Main()
  7. {
  8. var userRoles = new[] { "Guest", "Admin", "User" };
  9.  
  10. var highestRole = userRoles
  11. .Select(r => Enum.Parse(typeof(RoleType), r))
  12. .Max();
  13.  
  14.  
  15. Console.WriteLine("The type is: " + highestRole.GetType().Name);
  16. Console.WriteLine("The values is: {0}({1})",
  17. (int)highestRole,
  18. highestRole);
  19. }
  20. }
  21.  
  22. public enum RoleType
  23. {
  24. Default = 10,
  25. Guest = 20,
  26. User = 30,
  27. Admin = 40,
  28. Super = 50
  29. }
Success #stdin #stdout 0.05s 37088KB
stdin
Standard input is empty
stdout
The type is: RoleType
The values is: 40(Admin)