Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

int value from enum in C#

public enum Question
{
    Role = 2,
    ProjectFunding = 3,
    TotalEmployee = 4,
    NumberOfServers = 5,
    TopBusinessConcern = 6
}

int something = (int) Question.Role;
Comment

get int value from enum c#

public class EnumValue
{
    public string Name { get; set; }
    public int Value { get; set; }
}

public static List<EnumValue> GetValues<T>()
{
  List<EnumValue> values = new List<EnumValue>();
  foreach (var itemType in Enum.GetValues(typeof(YourEnumClass)))
  {
    //For each value of this enumeration, add a new EnumValue instance
    values.Add(new EnumValue()
               {
                 Name = Enum.GetName(typeof(YourEnumClass), itemType), 
                 Value = (int)itemType
                 });
  }
  return values;
}
Comment

PREVIOUS NEXT
Code Example
Csharp :: c# nullable generic 
Csharp :: on collision unity 
Csharp :: rigidbody.addforce not working 
Csharp :: get appsettings from app.config c# .net core 
Csharp :: list sum c# 
Csharp :: c# string methods 
Csharp :: callling class c# 
Csharp :: c# modulo 
Csharp :: linq string comparison case insensitive 
Csharp :: how to keep rigidbody2D upright unity 
Csharp :: c# list find index 
Csharp :: C# int array initial values 
Csharp :: listbox1.remove item c# 
Csharp :: unity detect when an object has been clicked 
Csharp :: cast from object to generic type c# 
Csharp :: how to use double in c# 
Csharp :: c# create log file 
Csharp :: c# get last array element 
Csharp :: How to use the protected keyword in C# 
Csharp :: c# read xml tag value 
Csharp :: generate UUID id for my entities 
Csharp :: dataGridView default error dialog handle 
Csharp :: upload a file selenium c# 
Csharp :: c# array of objects 
Csharp :: C# top down view player movement script 
Csharp :: how to make a character jump c# 
Csharp :: c# split multiple options 
Csharp :: .net mvc foreach index 
Csharp :: reference a class by string unity 
Csharp :: rgb to console color 
ADD CONTENT
Topic
Content
Source link
Name
5+7 =