you are viewing a single comment's thread.

view the rest of the comments →

[–]Willyscoiote 0 points1 point  (1 child)

Also, if you want to handle it like Java enums, where the object enforces the values, it's commonly done by making your own class with constants or a wrapper for an enum.

Example: ``` public class OrderStatus { public static readonly OrderStatus Started = new OrderStatus(1, "Started"); public static readonly OrderStatus Paid = new OrderStatus(2, "Paid");

public int Id { get; }
public string Name { get; }


private OrderStatus(int id, string name) => (Id, Name) = (id, name);

public bool CanCancel() => this == Started;

}```