My question is how can I get values of enum variable?

Please look at the attached screenshot… “hatas” is a flag-enum. And I want to
get “HasError” – “NameOrDisplayNameTooShort” errors to show them.
using System;
namespace CampaignManager.Enums
{
[Flags]
public enum CampaignCreaterUpdaterErrorMessage
{
NoError = 0,
HasError = 1,
NameOrDisplaynameTooShort = 2,
InvalidFirstName = 3,
}
}
I tried simply;
Messagebox.Show(hatas); // it's showing InvalidFirstName somehow...
Thank you very much for any help…
First thing: If you want to use the FlagsAttribute on your enum you need to define the values in powers of two like this:
To get parts of a flagged enum, try something like:
For getting the underlying value try casting:
In your example, ToString is getting called by default against the CampaignCreaterUpdaterErrorMessage enum which return the string representation of the enum.
By casting to an int, the underlying default type for enums, you get ToString on the integer value.