Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Cast int to enum in C#
//Title of this code //Rextester.Program.Main is the entry point for your code. Don't change it. //Compiler version 4.0.30319.17929 for Microsoft (R) .NET Framework 4.5 using System; using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; namespace Rextester { public class Program { public enum Suit : int { Spades = 0, Hearts = 1, Clubs = 2, Diamonds = 3 } public static void Main(string[] args) { //from string Console.WriteLine((Suit) Enum.Parse(typeof(Suit), "Clubs")); //from int Console.WriteLine((Suit)1); //From number you can also Console.WriteLine((Suit)Enum.ToObject(typeof(Suit) ,1)); } } }
run
|
edit
|
history
|
help
0
Hello world
Create HardwareConfigs
Student Cables
breadbank
Palindrome
Enum Extension
Nested Namespace
ch.murali krishna
random number generator using array
combof123usingloop