I am learning C#, and using visual studio. I try to specify identical values for multiple enumeration values by using one value as the underlying value of another.
namespace ConsoleApp1
{
enum test
{
east = 0,
west = east,
south = 2,
north = 3
}
internal class Program
{
static void Main(string[] args)
{
test myTest1 = test.east;
Console.WriteLine($"{myTest1}:{(byte)myTest1}");
Console.ReadKey();
}
}
}
It output:west:0
namespace ConsoleApp1
{
enum test
{
east = 0,
west = 1,
south = east,
north = 3
}
internal class Program
{
static void Main(string[] args)
{
test myTest1 = test.east;
Console.WriteLine($"{myTest1}:{(byte)myTest1}");
Console.ReadKey();
}
}
}
follow the output above, I thought it should be south:0
. But it turns out east:0
.
Why is that?