Answers for "c# int to enum"

C#
1

C# .net core convert int to enum

if (Enum.IsDefined(typeof(YourEnum), yourInt))
{
    return (YourEnum) yourInt;
}

  OR:

if (Enum.IsDefined(typeof(YourEnum), yourInt))
{
    return (YourEnum) Enum.ToObject(typeof(YourEnum), yourInt);
}
Posted by: Guest on April-27-2020
1

cast int to enum type c#

YourEnum foo = (YourEnum)yourInt;
Posted by: Guest on August-20-2021
0

cast int to enum type c#

YourEnum foo = (YourEnum)Enum.ToObject(typeof(YourEnum) , yourInt);
Posted by: Guest on August-20-2021

C# Answers by Framework

Browse Popular Code Answers by Language