Answers for "store string representation of enums"

C#
1

How can I cast string to enum?

YourEnum foo = (YourEnum) Enum.Parse(typeof(YourEnum), yourString);
Posted by: Guest on July-01-2021
0

Create Type from String Enum

const GENDERS = ["MALE", "FEMALE", "DIVERSE"] as const;
type Gender = typeof GENDERS[number];
Posted by: Guest on September-15-2021

C# Answers by Framework

Browse Popular Code Answers by Language