Please help me understand this code. Is this like an enumeration with objects instead of values? Is there are term or pattern that explains this process?
public class State
{
private State(String value)
{
Value = value;
}
public String Value { get; set; }
public static State Open => new State("Open");
public static State Closed => new State("Closed");
public static State YourOpen => new State("YourOpen");
public static State YourClosed => new State("YourClosed");
}
It seems to be a class that:
I had overlooked the private constructor. As @jacob-krall pointed out the typesafe enum
(coming from older Java) seems to suit best.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With