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

create enum from int c#

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

int something = (int) Question.Role;
Question something_else = (Question) something;
Comment

PREVIOUS NEXT
Code Example
Csharp :: dota2 
Csharp :: how to print using C# 
Csharp :: copy 2d arrays C# 
Csharp :: look rotation only on y axis in unity 
Csharp :: list removeall unity 
Csharp :: c# unity detect any keyboard input but not mouse input 
Csharp :: c# string to byte[] 
Csharp :: c# bytes to image 
Csharp :: convert object to array in c# 
Csharp :: c# latex 
Csharp :: serilog set log level 
Csharp :: get last 4 character c# 
Csharp :: system.io.directorynotfoundexception c# 
Csharp :: how to install jdk on linux manjaro 
Csharp :: rotate player unity 2d left and right 
Csharp :: c# dictionary to json 
Csharp :: how to check if file contains image c# 
Csharp :: decimal c# 2 digits 
Csharp :: c# adding to a list 
Csharp :: c# check lenght 
Csharp :: Net.ServicePointManager.SecurityProtocol .net framework 4 
Csharp :: increment operator c# 
Csharp :: how to check if the value is alphabet only in c# 
Csharp :: how to work with ascii in c# 
Csharp :: c# get application root path directory 
Csharp :: .net core copy directory to output 
Csharp :: github action get commit tag 
Csharp :: parent unity 
Csharp :: how to disable vsync in monogame 
Csharp :: How to catch Entity Framework Errors C# 
ADD CONTENT
Topic
Content
Source link
Name
8+7 =