Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

How can I cast string to enum?

YourEnum foo = (YourEnum) Enum.Parse(typeof(YourEnum), yourString);
Comment

casting string to enum type

string str = "Dog";
Animal animal = (Animal)Enum.Parse(typeof(Animal), str);  // Animal.Dog
Animal animal = (Animal)Enum.Parse(typeof(Animal), str, true); // case insensitive
Comment

PREVIOUS NEXT
Code Example
Csharp :: how to deactivate objects through scripts in unity 
Csharp :: round float c# 
Csharp :: c# afficher texte 
Csharp :: entity framework update child records 
Csharp :: c# get user appdata folder 
Csharp :: trigger collider unity 
Csharp :: how to run code without a gameobject unity 
Csharp :: c# datetime remove time 
Csharp :: c# create dynamic object 
Csharp :: unity spherecast 
Csharp :: how to set up blender with unity units 
Csharp :: c# datagridview filter textbox 
Csharp :: .net Core Get File Request 
Csharp :: c# foreach dictionary 
Csharp :: c# console foreground color 
Csharp :: difference between iqueryable and ienumerable c# 
Csharp :: c# multiply string 
Csharp :: Cursor Lock and Visible in Unity 
Csharp :: unity get child gameobject 
Csharp :: system.drawing.color from hex 
Csharp :: unity show colliders 
Csharp :: c# restclient timeout 
Csharp :: system.io.directorynotfoundexception c# 
Csharp :: how to remove vowels from a sttring using regex c# 
Csharp :: c# underscore variable 
Csharp :: c# messagebox result 
Csharp :: fade image out unity 
Csharp :: unity button onclick 
Csharp :: average c# 
Csharp :: generate entity model dot net core 
ADD CONTENT
Topic
Content
Source link
Name
8+3 =