Answers for "c# enum to int"

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

c# enum to int

Just cast the enum, e.g.
int something = (int) WeaponType.BFG;
Posted by: Guest on April-23-2021
2

c# enum syntax

enum State
{
	Idle,
    Walking,
    Running,
    Jumping,
    Climbing,
    Attacking
}
Posted by: Guest on September-15-2020
2

get enum value c#

int something = (int) Question.Role;
Posted by: Guest on March-17-2020
0

c# enum to int array

int[] b = Array.ConvertAll((int[])Enum.GetValues(typeof(TestEnum)), Convert.ToInt32);
Posted by: Guest on February-28-2020
0

C# enum

enum CellphoneBrand { 
        Samsung,
        Apple,
  		LG,
  		Nokia,
  		Huawei,
  		Motorola
    }
Posted by: Guest on November-08-2020

C# Answers by Framework

Browse Popular Code Answers by Language