C # Case Study of Enumeration type Traversal

Source: Internet
Author: User

C # Case Study of Enumeration type Traversal

  1. Using System;
  2. Using System. Collections. Generic;
  3. Using System. Linq;
  4. Using System. Text;
  5. Using System. Collections;

  6. Namespace ConsoleApplication2
  7. {
  8. Class Program
  9. {
  10. Public enum performance_error_type
  11. {
  12. // Explanation Error
  13. PARSE_ERROR = 1,
  14. // Error CMD
  15. BAD_CMD,
  16. }


  17. Static void Main (string [] args)
  18. {
  19. String cmd = "5 FAIL 1 \ n ";
  20. If (IsServRespFailCMD (cmd ));

  21. Console. ReadLine ();
  22. }

  23. Public static bool IsServRespFailCMD (string rcvedCMD)
  24. {
  25. Hashtable htFileCmd = new Hashtable ();
  26. String stdFileCmd = string. Empty;

  27. Foreach (int e in Enum. GetValues (typeof (pai_error_type )))
  28. {
  29. StdFileCmd = string. Format ("5 FAIL {0} \ n", e );
  30. HtFileCmd. Add (stdFileCmd, e );
  31. }

  32. If (htFileCmd. ContainsKey (rcvedCMD ))
  33. Return true;

  34. Return false;
  35. }
  36. }
  37. }

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.