Get the value of an Enum c#
public enum Vehicle: byte
{
Car,
Bike=3,
Truck,
Taxi,
}
Console.WriteLine((int)VehicleEnum.Car);
string vehicle = Vehicle.Bike.ToString();
Console.WriteLine(vehicle);
Output:
0
Bike
Get the value of an Enum c#
public enum Vehicle: byte
{
Car,
Bike=3,
Truck,
Taxi,
}
Console.WriteLine((int)VehicleEnum.Car);
string vehicle = Vehicle.Bike.ToString();
Console.WriteLine(vehicle);
Output:
0
Bike
c# get all enum values
var values = Enum.GetValues(typeof(Foos));
c# get enum name from value
string name=(weekdays)2;//returns weekdays which has value 2.Here weekdays is enum name
c# get value of object in enum
arrayName variable = (arrayName) index
//for example
Days day = (Days)3;
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us