Advertisement
Guest User

Untitled

a guest
Oct 22nd, 2014
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. public enum baseKey : uint
  2. {
  3. HKEY_CLASSES_ROOT = 0x80000000,
  4. HKEY_CURRENT_USER = 0x80000001,
  5. HKEY_LOCAL_MACHINE = 0x80000002,
  6. HKEY_USERS = 0x80000003,
  7. HKEY_CURRENT_CONFIG = 0x80000005
  8. }
  9.  
  10. (uint)Enum.Parse(typeof(baseKey), "HKEY_LOCAL_MACHINE")
  11.  
  12. uint key = 0;
  13. string s = "HKEY_LOCAL_MACHINE";
  14. try
  15. {
  16. key = (uint)Enum.Parse(typeof(baseKey), s);
  17. }
  18. catch(ArgumentException)
  19. {
  20. //unknown string or s is null
  21. }
  22.  
  23. baseKey e;
  24.  
  25. if ( Enum.TryParse(s, out e) )
  26. {
  27. ...
  28. }
  29.  
  30. var value = (uint) Enum.Parse(typeof(baseKey), someString);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement