Iteration über enum



  • Hallo,

    mich wundert es, dass ich im Forum nichts darüber gefunden habe.

    Wie kann ich über ein enum class iterieren?



  • Enum::GetValues...

    enum class Colors
    {
       Red, Green, Blue, Yellow
    };
    
       Console::WriteLine(  "The values of the Colors Enum are:" );
       Array^ a = Enum::GetValues( Colors::typeid );
       for ( Int32 i = 0; i < a->Length; i++ )
       {
          Object^ o = a->GetValue( i );
          Console::WriteLine(  "{0}", Enum::Format( Colors::typeid, o,  "D" ) );
       }
    

Anmelden zum Antworten