TylerBrinkley/Enums.NET

How to check next or previous

Closed this issue ยท 3 comments

Hi, I just found your lib, lifesaver!! ๐Ÿ‘ I am trying to replace the traditional Enum with your lib..

I'm outside a for/foreach loop, and would like to increment an Enum for e.g Submitted to Approved
how could I move through the enums

   Document.Status.Next()  // success/true, if false it was the last enum.
   Document.Status.NextOrLast()  //
   Document.Status.Previous()  //
   Document.Status.PreviousOrFirst()  //

Can I set a status from string, Document.Status = "Approved";?

thanks

how could I move through the enums

If your enum values are consecutive, why not just use the pre or post increment or decrement operators?

Can I set a status from string, Document.Status = "Approved";?

Assuming Status is an enum why not just set Document.Status = EnumName.Approved; where EnumName is the enum's type name? Are you getting the string value from somewhere else. If so you should use Document.Status = Enums.Parse<EnumName>(str); where EnumName is the enum's type name and str is the string value variable.

thanks much, you rock.

And yes, the UI is sending me strings which I need to deal with :)
You mean I can do Doc.Draft++ outside a for loop? if thats the case, thats all I need.
If possible do consider making the select list for dropdown an inbuilt function your lib ๐Ÿ˜ƒ

You should be able to do Document.Status++;.

I'm afraid adding UI specific features is out of scope of this library and also there are too many options to account for.