Answers for "enum with string values"

1

enum value to string

class Program.
static void Main(string[] args)
{
   Enum wkday = Weekday.Friday;
   Console.WriteLine("Enum string is '{0}'", wkday.ToString());
   Console.ReadKey();
}
Posted by: Guest on February-23-2021
0

Using enum values as string literals

public enum Country{
    SPAIN("España"),
    ITALY("Italia"),
    PORTUGAL("Portugal");


    private String value;

    Country(final String value) {
        this.value = value;
    }

    public String getValue() {
        return value;
    }

    @Override
    public String toString() {
        return this.getValue();
    }
}
Posted by: Guest on June-02-2021
1

enum value to string

class Program.
static void Main(string[] args)
{
   Enum wkday = Weekday.Friday;
   Console.WriteLine("Enum string is '{0}'", wkday.ToString());
   Console.ReadKey();
}
Posted by: Guest on February-23-2021
0

Using enum values as string literals

public enum Country{
    SPAIN("España"),
    ITALY("Italia"),
    PORTUGAL("Portugal");


    private String value;

    Country(final String value) {
        this.value = value;
    }

    public String getValue() {
        return value;
    }

    @Override
    public String toString() {
        return this.getValue();
    }
}
Posted by: Guest on June-02-2021

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language