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 , then yes, you must always put it on 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

Popular posts from this blog

c# - sqlDecimal to decimal clr stored procedure Unable to cast object of type 'System.Data.SqlTypes.SqlDecimal' to type 'System.IConvertible' -

Calling GetGUIThreadInfo from Outlook VBA -

Obfuscating Python code? -