c# - Do I always have to cast enum or am I doing something wrong? -
If I have such a very simple enum.
enum alignment {left, center, right}
Where I want to make datatype an integer, which I think is the default, and values Is to be omitted = 0, center = 1, right = 2
but if I try to assume and value like
header.Alignment = alignment.center;
I am told that I have to put alignment. Which is not a big deal but I am wondering if I am doing something wrong or that is the way to work.
If header.Anignment
is type int
.
You can create header.Alignment
type alignment
, and then you will never be able to enter it if you are working with legacy or third-party code If you accept only int
, then you are out of luck.
Comments
Post a Comment